Share via


IMigrator Interface

Definition

The main service used to generated an EF Core Migrations script or migrate a database directly.

public interface IMigrator
type IMigrator = interface
Public Interface IMigrator

Remarks

The service lifetime is Scoped. This means that each DbContext instance will use its own instance of this service. The implementation may depend on other services registered with any lifetime. The implementation does not need to be thread-safe.

See Database migrations for more information and examples.

Methods

GenerateScript(String, String, Boolean)

Generates a SQL script to migrate a database either in its entirety, or starting and ending at specified migrations.

GenerateScript(String, String, MigrationsSqlGenerationOptions)

Generates a SQL script to migrate a database either in its entirety, or starting and ending at specified migrations.

HasPendingModelChanges()

Returns true if the model has pending changes to be applied.

Migrate(String)

Migrates the database to either a specified target migration or up to the latest migration that exists in the IMigrationsAssembly.

MigrateAsync(String, CancellationToken)

Migrates the database to either a specified target migration or up to the latest migration that exists in the IMigrationsAssembly.

Applies to