Skip to main content
.NET 8.0+

Session.UpdateSchemaAsync(CancellationToken, Type[]) Method

Asynchronously updates a data store’s schema according to the class descriptions of the specified types.

Namespace: DevExpress.Xpo

Assembly: DevExpress.Xpo.v24.2.dll

Declaration

public Task UpdateSchemaAsync(
    CancellationToken cancellationToken,
    params Type[] types
)

Parameters

Name Type Description
cancellationToken CancellationToken

A CancellationToken object that delivers a cancellation notice to the running operation.

types Type[]

An array of Type objects that represent the types of objects for which schema should be created in the data store.

Returns

Type Description
Task

A Task that updates a data store’s schema according to the class descriptions of the specified types.

Remarks

using System;
using System.Threading;
using System.Threading.Tasks;
using DevExpress.Xpo;
using DevExpress.Xpo.DB;
// ...
public async Task CreateDatabase(string connectionString, params Type[] persistentTypes) {
    using(IDataLayer dal = XpoDefault.GetDataLayer(connectionString, AutoCreateOption.DatabaseAndSchema)) {
        UnitOfWork uow = new UnitOfWork(dal);
        await uow.UpdateSchemaAsync(CancellationToken.None, persistentTypes);
        await uow.CreateObjectTypeRecordsAsync(CancellationToken.None, persistentTypes);
    }
}
See Also