Note

Access to this page requires authorization. You can try signing in or .

Access to this page requires authorization. You can try .

RelationalDatabaseFacadeExtensions.Migrate Method

Definition

Namespace:
Microsoft.EntityFrameworkCore
Assembly:
Microsoft.EntityFrameworkCore.Relational.dll
Package:
Microsoft.EntityFrameworkCore.Relational v1.0.6
Package:
Microsoft.EntityFrameworkCore.Relational v1.1.6
Package:
Microsoft.EntityFrameworkCore.Relational v10.0.0
Package:
Microsoft.EntityFrameworkCore.Relational v2.0.3
Package:
Microsoft.EntityFrameworkCore.Relational v2.1.11
Package:
Microsoft.EntityFrameworkCore.Relational v2.2.6
Package:
Microsoft.EntityFrameworkCore.Relational v3.0.0
Package:
Microsoft.EntityFrameworkCore.Relational v3.1.0
Package:
Microsoft.EntityFrameworkCore.Relational v5.0.0
Package:
Microsoft.EntityFrameworkCore.Relational v6.0.0
Package:
Microsoft.EntityFrameworkCore.Relational v7.0.0
Package:
Microsoft.EntityFrameworkCore.Relational v8.0.0
Package:
Microsoft.EntityFrameworkCore.Relational v9.0.0

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Overloads

Name Description
Migrate(DatabaseFacade)

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

Migrate(DatabaseFacade, String)

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

Migrate(DatabaseFacade)

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
Source:
RelationalDatabaseFacadeExtensions.cs

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

public static void Migrate(this Microsoft.EntityFrameworkCore.Infrastructure.DatabaseFacade databaseFacade);
[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 void Migrate(this Microsoft.EntityFrameworkCore.Infrastructure.DatabaseFacade databaseFacade);
static member Migrate : Microsoft.EntityFrameworkCore.Infrastructure.DatabaseFacade -> unit
[<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 Migrate : Microsoft.EntityFrameworkCore.Infrastructure.DatabaseFacade -> unit
<Extension()>
Public Sub Migrate (databaseFacade As DatabaseFacade)

Parameters

databaseFacade
DatabaseFacade

The DatabaseFacade for the context.

Attributes

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

Migrate(DatabaseFacade, String)

Source:
RelationalDatabaseFacadeExtensions.cs
Source:
RelationalDatabaseFacadeExtensions.cs

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 void Migrate(this Microsoft.EntityFrameworkCore.Infrastructure.DatabaseFacade databaseFacade, string? targetMigration);
[<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 Migrate : Microsoft.EntityFrameworkCore.Infrastructure.DatabaseFacade * string -> unit
<Extension()>
Public Sub Migrate (databaseFacade As DatabaseFacade, targetMigration As String)

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.

Attributes

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


Feedback

Was this page helpful?