Session.UpdateSchemaAsync(CancellationToken, XPClassInfo[]) Method
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
Declaration
Parameters
Name | Type | Description |
---|---|---|
cancellationToken | CancellationToken | A CancellationToken object that delivers a cancellation notice to the running operation. |
types | XPClassInfo[] | An array of XPClassInfo objects that specify the types of objects for which schema should be created in the data store. |
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