Delen via


RelationalDatabaseFacadeExtensions.MigrateAsync Method

Definition

Overloads

MigrateAsync(DatabaseFacade, CancellationToken)

Asynchronously applies any pending migrations for the context to the database. Will create the database if it does not already exist.

MigrateAsync(DatabaseFacade, String, CancellationToken)

Asynchronously applies migrations for the context to the database. Will create the database if it does not already exist.

MigrateAsync(DatabaseFacade, CancellationToken)

Source:
RelationalDatabaseFacadeExtensions.cs
Source:
RelationalDatabaseFacadeExtensions.cs
Source:
RelationalDatabaseFacadeExtensions.cs
Source:
RelationalDatabaseFacadeExtensions.cs
Source:
RelationalDatabaseFacadeExtensions.cs
Source:
RelationalDatabaseFacadeExtensions.cs
Source:
RelationalDatabaseFacadeExtensions.cs
Source:
RelationalDatabaseFacadeExtensions.cs
Source:
RelationalDatabaseFacadeExtensions.cs

Asynchronously applies any pending migrations for the context to the database. Will create the database if it does not already exist.

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

Parameters

databaseFacade
DatabaseFacade

The DatabaseFacade for the context.

cancellationToken
CancellationToken

A CancellationToken to observe while waiting for the task to complete.

Returns

A task that represents the asynchronous migration operation.

Attributes

Exceptions

Remarks

Note that this API is mutually exclusive with EnsureCreated(). EnsureCreated() does not use migrations to create the database and therefore the database that is created cannot be later updated using migrations.

See Database migrations for more information and examples.

Applies to

MigrateAsync(DatabaseFacade, String, CancellationToken)

Source:
RelationalDatabaseFacadeExtensions.cs

Asynchronously applies migrations for the context to the database. Will create the database if it does not already exist.

[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

Parameters

databaseFacade
DatabaseFacade

The DatabaseFacade for the context.

targetMigration
String

The target migration to migrate the database to, or null to migrate to the latest.

cancellationToken
CancellationToken

A CancellationToken to observe while waiting for the task to complete.

Returns

A task that represents the asynchronous migration operation.

Attributes

Exceptions

Remarks

Note that this API is mutually exclusive with EnsureCreated(). EnsureCreated() does not use migrations to create the database and therefore the database that is created cannot be later updated using migrations.

See Database migrations for more information and examples.

Applies to