Session.UpdateSchemaAsync(CancellationToken, XPClassInfo[]) Method
In This Article
Asynchronously updates the database schema to support the persistence of the objects with the specified metadata information.
Namespace: DevExpress.Xpo
Assembly: DevExpress.Xpo.v24.2.dll
NuGet Package: DevExpress.Xpo
#Declaration
public Task UpdateSchemaAsync(
CancellationToken cancellationToken,
params XPClassInfo[] types
)
#Parameters
Name | Type | Description |
---|---|---|
cancellation |
Cancellation |
A Cancellation |
types | XPClass |
An array of XPClass |
#Returns
Type | Description |
---|---|
Task | A Task that updates the database schema to support the persistence of the objects with the specified metadata information. |
#Remarks
using System.Threading;
using System.Threading.Tasks;
using DevExpress.Xpo;
using DevExpress.Xpo.DB;
using DevExpress.Xpo.Metadata;
// ...
public async Task CreateDatabase(string connectionString, params XPClassInfo[] persistentClasses) {
using(IDataLayer dal = XpoDefault.GetDataLayer(connectionString, AutoCreateOption.DatabaseAndSchema)) {
UnitOfWork uow = new UnitOfWork(dal);
await uow.UpdateSchemaAsync(CancellationToken.None, persistentClasses);
await uow.CreateObjectTypeRecordsAsync(CancellationToken.None, persistentClasses);
}
}
See Also