共用方式為


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() 不會使用移轉來建立資料庫,因此無法稍後使用移轉來更新所建立的資料庫。

如需詳細資訊和範例 ,請參閱資料庫移轉

適用於