RelationalDatabaseFacadeExtensions.MigrateAsync 方法

定义

将上下文的任何挂起迁移异步应用于数据库。 如果数据库尚不存在,将创建该数据库。

public static System.Threading.Tasks.Task MigrateAsync (this Microsoft.EntityFrameworkCore.Infrastructure.DatabaseFacade databaseFacade, System.Threading.CancellationToken cancellationToken = default);
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Migrations operations are not supported with NativeAOT Use a migration bundle or an alternate way of executing migration operations.")]
public static System.Threading.Tasks.Task MigrateAsync (this Microsoft.EntityFrameworkCore.Infrastructure.DatabaseFacade databaseFacade, System.Threading.CancellationToken cancellationToken = default);
static member MigrateAsync : Microsoft.EntityFrameworkCore.Infrastructure.DatabaseFacade * System.Threading.CancellationToken -> System.Threading.Tasks.Task
[<System.Diagnostics.CodeAnalysis.RequiresDynamicCode("Migrations operations are not supported with NativeAOT Use a migration bundle or an alternate way of executing migration operations.")>]
static member MigrateAsync : Microsoft.EntityFrameworkCore.Infrastructure.DatabaseFacade * System.Threading.CancellationToken -> System.Threading.Tasks.Task
<Extension()>
Public Function MigrateAsync (databaseFacade As DatabaseFacade, Optional cancellationToken As CancellationToken = Nothing) As Task

参数

databaseFacade
DatabaseFacade

DatabaseFacade上下文的 。

cancellationToken
CancellationToken

等待 CancellationToken 任务完成时要观察的 。

返回

表示异步迁移操作的任务。

属性

例外

注解

请注意,此 API 与 EnsureCreated()互斥。 EnsureCreated() 不使用迁移来创建数据库,因此以后无法使用迁移更新所创建的数据库。

有关详细信息和示例 ,请参阅数据库迁移

适用于