Migration Class

Definition

A base class inherited by each EF Core migration.

public abstract class Migration
type Migration = class
Public MustInherit Class Migration
Inheritance
Migration

Constructors

Migration()

Creates a Migration instance.

Fields

InitialDatabase

The migration identifier for the empty database.

Properties

ActiveProvider

The name of the current database provider.

This can be used to write conditional code in the migration such that different changes can be made to the database depending on the type of database being used.

DownOperations

The MigrationOperations that will migrate the database 'down'.

That is, those operations that need to be applied to the database to take it from the state left in by this migration so that it returns to the state that it was in before this migration was applied.

TargetModel

The IModel that the database will map to after the migration has been applied.

UpOperations

The MigrationOperations that will migrate the database 'up'.

That is, those operations that need to be applied to the database to take it from the state left in by the previous migration so that it is up-to-date with regard to this migration.

Methods

BuildTargetModel(ModelBuilder)

Implemented to build the TargetModel.

Down(MigrationBuilder)

Builds the operations that will migrate the database 'down'.

That is, builds the operations that will take the database from the state left in by this migration so that it returns to the state that it was in before this migration was applied.

This method must be overridden in each class the inherits from Migration if both 'up' and 'down' migrations are to be supported. If it is not overridden, then calling it will throw and it will not be possible to migrate in the 'down' direction.

Up(MigrationBuilder)

Builds the operations that will migrate the database 'up'.

That is, builds the operations that will take the database from the state left in by the previous migration so that it is up-to-date with regard to this migration.

This method must be overridden in each class the inherits from Migration.

Applies to