RelationalDatabaseFacadeExtensions.Migrate Method

Definition

Overloads

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

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

C#
public static void Migrate (this Microsoft.EntityFrameworkCore.Infrastructure.DatabaseFacade databaseFacade);
C#
[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);

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

Entity Framework Core 9.0 and other versions
Product Versions
Entity Framework Core 1.0, 1.1, 2.0, 2.1, 2.2, 3.0, 3.1, 5.0, 6.0, 7.0, 8.0, 9.0

Migrate(DatabaseFacade, String)

Source:
RelationalDatabaseFacadeExtensions.cs

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

C#
[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);

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

Entity Framework Core 9.0
Product Versions
Entity Framework Core 9.0