RelationalDatabaseFacadeExtensions.MigrateAsync 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
多載
| 名稱 | Description |
|---|---|
| MigrateAsync(DatabaseFacade, CancellationToken) |
非同步地將上下文中待處理的遷移資料套用到資料庫。 如果資料庫還不存在,我會建立。 |
| MigrateAsync(DatabaseFacade, String, CancellationToken) |
非同步地將上下文遷移套用於資料庫。 如果資料庫還不存在,我會建立。 |
MigrateAsync(DatabaseFacade, CancellationToken)
非同步地將上下文中待處理的遷移資料套用到資料庫。 如果資料庫還不存在,我會建立。
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
A CancellationToken 在等待任務完成時觀察。
傳回
一個代表非同步遷移操作的任務。
- 屬性
例外狀況
備註
請注意,此 API 與 EnsureCreated()是互斥的。 EnsureCreated() 不使用遷移來建立資料庫,因此所建立的資料庫無法透過遷移後續更新。
更多資訊與範例請參見 資料庫遷移 。
適用於
MigrateAsync(DatabaseFacade, String, CancellationToken)
非同步地將上下文遷移套用於資料庫。 如果資料庫還不存在,我會建立。
[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, string? targetMigration, 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.")>]
static member MigrateAsync : Microsoft.EntityFrameworkCore.Infrastructure.DatabaseFacade * string * System.Threading.CancellationToken -> System.Threading.Tasks.Task
<Extension()>
Public Function MigrateAsync (databaseFacade As DatabaseFacade, targetMigration As String, Optional cancellationToken As CancellationToken = Nothing) As Task
參數
- databaseFacade
- DatabaseFacade
這是 DatabaseFacade 給你背景的。
- targetMigration
- String
目標是遷移資料庫到 null 或遷移到最新版本。
- cancellationToken
- CancellationToken
A CancellationToken 在等待任務完成時觀察。
傳回
一個代表非同步遷移操作的任務。
- 屬性
例外狀況
備註
請注意,此 API 與 EnsureCreated()是互斥的。 EnsureCreated() 不使用遷移來建立資料庫,因此所建立的資料庫無法透過遷移後續更新。
更多資訊與範例請參見 資料庫遷移 。