Table of Contents

Class MigrationsSqlGenerator

Namespace
Microsoft.EntityFrameworkCore.Migrations
Assembly
Microsoft.EntityFrameworkCore.Relational.dll

Generates the SQL in MigrationCommand objects that can then be executed or scripted from a list of MigrationOperations.

This class is typically inherited by database providers to customize the SQL generation.

The service lifetime is Scoped. This means that each Microsoft.EntityFrameworkCore.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.

public class MigrationsSqlGenerator : IMigrationsSqlGenerator
Inheritance
MigrationsSqlGenerator
Implements
Inherited Members

Constructors

MigrationsSqlGenerator(MigrationsSqlGeneratorDependencies)

Creates a new MigrationsSqlGenerator instance using the given dependencies.

public MigrationsSqlGenerator(MigrationsSqlGeneratorDependencies dependencies)

Parameters

dependencies MigrationsSqlGeneratorDependencies

Parameter object containing dependencies for this service.

Properties

Dependencies

Parameter object containing dependencies for this service.

protected virtual MigrationsSqlGeneratorDependencies Dependencies { get; }

Property Value

MigrationsSqlGeneratorDependencies

Options

Gets or sets the options to use when generating commands.

protected virtual MigrationsSqlGenerationOptions Options { get; set; }

Property Value

MigrationsSqlGenerationOptions

SqlGenerator

protected virtual IUpdateSqlGenerator SqlGenerator { get; }

Property Value

IUpdateSqlGenerator

VersionComparer

Gets a comparer that can be used to compare two product versions.

protected virtual IComparer<string> VersionComparer { get; }

Property Value

IComparer<string>

Methods

CheckConstraint(AddCheckConstraintOperation, IModel, MigrationCommandListBuilder)

Generates a SQL fragment for a check constraint of an AddCheckConstraintOperation.

protected virtual void CheckConstraint(AddCheckConstraintOperation operation, IModel model, MigrationCommandListBuilder builder)

Parameters

operation AddCheckConstraintOperation

The operation.

model IModel

The target model which may be null if the operations exist without a model.

builder MigrationCommandListBuilder

The command builder to use to add the SQL fragment.

ColumnDefinition(AddColumnOperation, IModel, MigrationCommandListBuilder)

Generates a SQL fragment for a column definition in an AddColumnOperation.

protected virtual void ColumnDefinition(AddColumnOperation operation, IModel model, MigrationCommandListBuilder builder)

Parameters

operation AddColumnOperation

The operation.

model IModel

The target model which may be null if the operations exist without a model.

builder MigrationCommandListBuilder

The command builder to use to add the SQL fragment.

ColumnDefinition(string, string, string, ColumnOperation, IModel, MigrationCommandListBuilder)

Generates a SQL fragment for a column definition for the given column metadata.

protected virtual void ColumnDefinition(string schema, string table, string name, ColumnOperation operation, IModel model, MigrationCommandListBuilder builder)

Parameters

schema string

The schema that contains the table, or null to use the default schema.

table string

The table that contains the column.

name string

The column name.

operation ColumnOperation

The column metadata.

model IModel

The target model which may be null if the operations exist without a model.

builder MigrationCommandListBuilder

The command builder to use to add the SQL fragment.

ColumnList(string[])

Concatenates the given column names into a DelimitIdentifier(string) separated list.

protected virtual string ColumnList(string[] columns)

Parameters

columns string[]

The column names.

Returns

string

The column list.

ComputedColumnDefinition(string, string, string, ColumnOperation, IModel, MigrationCommandListBuilder)

Generates a SQL fragment for a computed column definition for the given column metadata.

protected virtual void ComputedColumnDefinition(string schema, string table, string name, ColumnOperation operation, IModel model, MigrationCommandListBuilder builder)

Parameters

schema string

The schema that contains the table, or null to use the default schema.

table string

The table that contains the column.

name string

The column name.

operation ColumnOperation

The column metadata.

model IModel

The target model which may be null if the operations exist without a model.

builder MigrationCommandListBuilder

The command builder to use to add the SQL fragment.

CreateTableCheckConstraints(CreateTableOperation, IModel, MigrationCommandListBuilder)

Generates a SQL fragment for the check constraints of a CreateTableOperation.

protected virtual void CreateTableCheckConstraints(CreateTableOperation operation, IModel model, MigrationCommandListBuilder builder)

Parameters

operation CreateTableOperation

The operation.

model IModel

The target model which may be null if the operations exist without a model.

builder MigrationCommandListBuilder

The command builder to use to add the SQL fragment.

CreateTableColumns(CreateTableOperation, IModel, MigrationCommandListBuilder)

Generates a SQL fragment for the column definitions in an CreateTableOperation.

protected virtual void CreateTableColumns(CreateTableOperation operation, IModel model, MigrationCommandListBuilder builder)

Parameters

operation CreateTableOperation

The operation.

model IModel

The target model which may be null if the operations exist without a model.

builder MigrationCommandListBuilder

The command builder to use to add the SQL fragment.

CreateTableConstraints(CreateTableOperation, IModel, MigrationCommandListBuilder)

Generates a SQL fragment for the constraints of a CreateTableOperation.

protected virtual void CreateTableConstraints(CreateTableOperation operation, IModel model, MigrationCommandListBuilder builder)

Parameters

operation CreateTableOperation

The operation.

model IModel

The target model which may be null if the operations exist without a model.

builder MigrationCommandListBuilder

The command builder to use to add the SQL fragment.

CreateTableForeignKeys(CreateTableOperation, IModel, MigrationCommandListBuilder)

Generates a SQL fragment for the foreign key constraints of a CreateTableOperation.

protected virtual void CreateTableForeignKeys(CreateTableOperation operation, IModel model, MigrationCommandListBuilder builder)

Parameters

operation CreateTableOperation

The operation.

model IModel

The target model which may be null if the operations exist without a model.

builder MigrationCommandListBuilder

The command builder to use to add the SQL fragment.

CreateTablePrimaryKeyConstraint(CreateTableOperation, IModel, MigrationCommandListBuilder)

Generates a SQL fragment for the primary key constraint of a CreateTableOperation.

protected virtual void CreateTablePrimaryKeyConstraint(CreateTableOperation operation, IModel model, MigrationCommandListBuilder builder)

Parameters

operation CreateTableOperation

The operation.

model IModel

The target model which may be null if the operations exist without a model.

builder MigrationCommandListBuilder

The command builder to use to add the SQL fragment.

CreateTableUniqueConstraints(CreateTableOperation, IModel, MigrationCommandListBuilder)

Generates a SQL fragment for the unique constraints of a CreateTableOperation.

protected virtual void CreateTableUniqueConstraints(CreateTableOperation operation, IModel model, MigrationCommandListBuilder builder)

Parameters

operation CreateTableOperation

The operation.

model IModel

The target model which may be null if the operations exist without a model.

builder MigrationCommandListBuilder

The command builder to use to add the SQL fragment.

DefaultValue(object, string, string, MigrationCommandListBuilder)

Generates a SQL fragment for the default constraint of a column.

protected virtual void DefaultValue(object defaultValue, string defaultValueSql, string columnType, MigrationCommandListBuilder builder)

Parameters

defaultValue object

The default value for the column.

defaultValueSql string

The SQL expression to use for the column's default constraint.

columnType string

Store/database type of the column.

builder MigrationCommandListBuilder

The command builder to use to add the SQL fragment.

EndStatement(MigrationCommandListBuilder, bool)

Generates a SQL fragment to terminate the SQL command.

protected virtual void EndStatement(MigrationCommandListBuilder builder, bool suppressTransaction = false)

Parameters

builder MigrationCommandListBuilder

The command builder to use to add the SQL fragment.

suppressTransaction bool

Indicates whether or not transactions should be suppressed while executing the built command.

FindEntityTypes(IModel, string, string)

Finds all Microsoft.EntityFrameworkCore.Metadata.IEntityTypes that are mapped to the given table.

[Obsolete("Use model?.GetRelationalModel().FindTable()")]
protected virtual IEnumerable<IEntityType> FindEntityTypes(IModel model, string schema, string tableName)

Parameters

model IModel

The target model which may be null if the operations exist without a model.

schema string

The schema that contains the table, or null to use the default schema.

tableName string

The table name.

Returns

IEnumerable<IEntityType>

The list of types, which may be empty if no types are mapped to the given table.

FindProperty(IModel, string, string, string)

Finds some Microsoft.EntityFrameworkCore.Metadata.IProperty mapped to the given column.

If multiple properties map to the same column, then the property returned is one chosen arbitrarily. The model validator ensures that all properties mapped to a given column have consistent configuration.

[Obsolete("Use model?.GetRelationalModel().FindTable().FindColumn()")]
protected virtual IProperty FindProperty(IModel model, string schema, string tableName, string columnName)

Parameters

model IModel

The target model which may be null if the operations exist without a model.

schema string

The schema that contains the table, or null to use the default schema.

tableName string

The name of the table that contains the column.

columnName string

The column name.

Returns

IProperty

The property found, or null if no property maps to the given column.

ForeignKeyAction(ReferentialAction, MigrationCommandListBuilder)

Generates a SQL fragment for the given referential action.

protected virtual void ForeignKeyAction(ReferentialAction referentialAction, MigrationCommandListBuilder builder)

Parameters

referentialAction ReferentialAction

The referential action.

builder MigrationCommandListBuilder

The command builder to use to add the SQL fragment.

ForeignKeyConstraint(AddForeignKeyOperation, IModel, MigrationCommandListBuilder)

Generates a SQL fragment for a foreign key constraint of an AddForeignKeyOperation.

protected virtual void ForeignKeyConstraint(AddForeignKeyOperation operation, IModel model, MigrationCommandListBuilder builder)

Parameters

operation AddForeignKeyOperation

The operation.

model IModel

The target model which may be null if the operations exist without a model.

builder MigrationCommandListBuilder

The command builder to use to add the SQL fragment.

Generate(AddCheckConstraintOperation, IModel, MigrationCommandListBuilder)

Builds commands for the given AddCheckConstraintOperation by making calls on the given MigrationCommandListBuilder, and then terminates the final command.

protected virtual void Generate(AddCheckConstraintOperation operation, IModel model, MigrationCommandListBuilder builder)

Parameters

operation AddCheckConstraintOperation

The operation.

model IModel

The target model which may be null if the operations exist without a model.

builder MigrationCommandListBuilder

The command builder to use to build the commands.

Generate(AddColumnOperation, IModel, MigrationCommandListBuilder, bool)

Builds commands for the given AddColumnOperation by making calls on the given MigrationCommandListBuilder.

protected virtual void Generate(AddColumnOperation operation, IModel model, MigrationCommandListBuilder builder, bool terminate = true)

Parameters

operation AddColumnOperation

The operation.

model IModel

The target model which may be null if the operations exist without a model.

builder MigrationCommandListBuilder

The command builder to use to build the commands.

terminate bool

Indicates whether or not to terminate the command after generating SQL for the operation.

Generate(AddForeignKeyOperation, IModel, MigrationCommandListBuilder, bool)

Builds commands for the given AddForeignKeyOperation by making calls on the given MigrationCommandListBuilder.

protected virtual void Generate(AddForeignKeyOperation operation, IModel model, MigrationCommandListBuilder builder, bool terminate = true)

Parameters

operation AddForeignKeyOperation

The operation.

model IModel

The target model which may be null if the operations exist without a model.

builder MigrationCommandListBuilder

The command builder to use to build the commands.

terminate bool

Indicates whether or not to terminate the command after generating SQL for the operation.

Generate(AddPrimaryKeyOperation, IModel, MigrationCommandListBuilder, bool)

Builds commands for the given AddPrimaryKeyOperation by making calls on the given MigrationCommandListBuilder.

protected virtual void Generate(AddPrimaryKeyOperation operation, IModel model, MigrationCommandListBuilder builder, bool terminate = true)

Parameters

operation AddPrimaryKeyOperation

The operation.

model IModel

The target model which may be null if the operations exist without a model.

builder MigrationCommandListBuilder

The command builder to use to build the commands.

terminate bool

Indicates whether or not to terminate the command after generating SQL for the operation.

Generate(AddUniqueConstraintOperation, IModel, MigrationCommandListBuilder)

Builds commands for the given AddUniqueConstraintOperation by making calls on the given MigrationCommandListBuilder, and then terminates the final command.

protected virtual void Generate(AddUniqueConstraintOperation operation, IModel model, MigrationCommandListBuilder builder)

Parameters

operation AddUniqueConstraintOperation

The operation.

model IModel

The target model which may be null if the operations exist without a model.

builder MigrationCommandListBuilder

The command builder to use to build the commands.

Generate(AlterColumnOperation, IModel, MigrationCommandListBuilder)

Can be overridden by database providers to build commands for the given AlterColumnOperation by making calls on the given MigrationCommandListBuilder.

Note that the default implementation of this method throws NotImplementedException. Providers must override if they are to support this kind of operation.

protected virtual void Generate(AlterColumnOperation operation, IModel model, MigrationCommandListBuilder builder)

Parameters

operation AlterColumnOperation

The operation.

model IModel

The target model which may be null if the operations exist without a model.

builder MigrationCommandListBuilder

The command builder to use to build the commands.

Generate(AlterDatabaseOperation, IModel, MigrationCommandListBuilder)

Can be overridden by database providers to build commands for the given AlterDatabaseOperation by making calls on the given MigrationCommandListBuilder.

Note that there is no default implementation of this method. Providers must override if they are to support this kind of operation.

protected virtual void Generate(AlterDatabaseOperation operation, IModel model, MigrationCommandListBuilder builder)

Parameters

operation AlterDatabaseOperation

The operation.

model IModel

The target model which may be null if the operations exist without a model.

builder MigrationCommandListBuilder

The command builder to use to build the commands.

Generate(AlterSequenceOperation, IModel, MigrationCommandListBuilder)

Builds commands for the given AlterSequenceOperation by making calls on the given MigrationCommandListBuilder, and then terminates the final command.

protected virtual void Generate(AlterSequenceOperation operation, IModel model, MigrationCommandListBuilder builder)

Parameters

operation AlterSequenceOperation

The operation.

model IModel

The target model which may be null if the operations exist without a model.

builder MigrationCommandListBuilder

The command builder to use to build the commands.

Generate(AlterTableOperation, IModel, MigrationCommandListBuilder)

Can be overridden by database providers to build commands for the given AlterTableOperation by making calls on the given MigrationCommandListBuilder.

Note that the default implementation of this method does nothing because there is no common metadata relating to this operation. Providers only need to override this method if they have some provider-specific annotations that must be handled.

protected virtual void Generate(AlterTableOperation operation, IModel model, MigrationCommandListBuilder builder)

Parameters

operation AlterTableOperation

The operation.

model IModel

The target model which may be null if the operations exist without a model.

builder MigrationCommandListBuilder

The command builder to use to build the commands.

Generate(CreateIndexOperation, IModel, MigrationCommandListBuilder, bool)

Builds commands for the given CreateIndexOperation by making calls on the given MigrationCommandListBuilder.

protected virtual void Generate(CreateIndexOperation operation, IModel model, MigrationCommandListBuilder builder, bool terminate = true)

Parameters

operation CreateIndexOperation

The operation.

model IModel

The target model which may be null if the operations exist without a model.

builder MigrationCommandListBuilder

The command builder to use to build the commands.

terminate bool

Indicates whether or not to terminate the command after generating SQL for the operation.

Generate(CreateSequenceOperation, IModel, MigrationCommandListBuilder)

Builds commands for the given CreateSequenceOperation by making calls on the given MigrationCommandListBuilder, and then terminates the final command.

protected virtual void Generate(CreateSequenceOperation operation, IModel model, MigrationCommandListBuilder builder)

Parameters

operation CreateSequenceOperation

The operation.

model IModel

The target model which may be null if the operations exist without a model.

builder MigrationCommandListBuilder

The command builder to use to build the commands.

Generate(CreateTableOperation, IModel, MigrationCommandListBuilder, bool)

Builds commands for the given CreateTableOperation by making calls on the given MigrationCommandListBuilder.

protected virtual void Generate(CreateTableOperation operation, IModel model, MigrationCommandListBuilder builder, bool terminate = true)

Parameters

operation CreateTableOperation

The operation.

model IModel

The target model which may be null if the operations exist without a model.

builder MigrationCommandListBuilder

The command builder to use to build the commands.

terminate bool

Indicates whether or not to terminate the command after generating SQL for the operation.

Generate(DeleteDataOperation, IModel, MigrationCommandListBuilder)

Builds commands for the given DeleteDataOperation by making calls on the given MigrationCommandListBuilder, and then terminates the final command.

protected virtual void Generate(DeleteDataOperation operation, IModel model, MigrationCommandListBuilder builder)

Parameters

operation DeleteDataOperation

The operation.

model IModel

The target model which may be null if the operations exist without a model.

builder MigrationCommandListBuilder

The command builder to use to build the commands.

Generate(DropCheckConstraintOperation, IModel, MigrationCommandListBuilder)

Builds commands for the given DropCheckConstraintOperation by making calls on the given MigrationCommandListBuilder, and then terminates the final command.

protected virtual void Generate(DropCheckConstraintOperation operation, IModel model, MigrationCommandListBuilder builder)

Parameters

operation DropCheckConstraintOperation

The operation.

model IModel

The target model which may be null if the operations exist without a model.

builder MigrationCommandListBuilder

The command builder to use to build the commands.

Generate(DropColumnOperation, IModel, MigrationCommandListBuilder, bool)

Builds commands for the given DropColumnOperation by making calls on the given MigrationCommandListBuilder.

protected virtual void Generate(DropColumnOperation operation, IModel model, MigrationCommandListBuilder builder, bool terminate = true)

Parameters

operation DropColumnOperation

The operation.

model IModel

The target model which may be null if the operations exist without a model.

builder MigrationCommandListBuilder

The command builder to use to build the commands.

terminate bool

Indicates whether or not to terminate the command after generating SQL for the operation.

Generate(DropForeignKeyOperation, IModel, MigrationCommandListBuilder, bool)

Builds commands for the given DropForeignKeyOperation by making calls on the given MigrationCommandListBuilder.

protected virtual void Generate(DropForeignKeyOperation operation, IModel model, MigrationCommandListBuilder builder, bool terminate = true)

Parameters

operation DropForeignKeyOperation

The operation.

model IModel

The target model which may be null if the operations exist without a model.

builder MigrationCommandListBuilder

The command builder to use to build the commands.

terminate bool

Indicates whether or not to terminate the command after generating SQL for the operation.

Generate(DropIndexOperation, IModel, MigrationCommandListBuilder, bool)

Can be overridden by database providers to build commands for the given DropIndexOperation by making calls on the given MigrationCommandListBuilder.

Note that the default implementation of this method throws NotImplementedException. Providers must override if they are to support this kind of operation.

protected virtual void Generate(DropIndexOperation operation, IModel model, MigrationCommandListBuilder builder, bool terminate = true)

Parameters

operation DropIndexOperation

The operation.

model IModel

The target model which may be null if the operations exist without a model.

builder MigrationCommandListBuilder

The command builder to use to build the commands.

terminate bool

Indicates whether or not to terminate the command after generating SQL for the operation.

Generate(DropPrimaryKeyOperation, IModel, MigrationCommandListBuilder, bool)

Builds commands for the given DropPrimaryKeyOperation by making calls on the given MigrationCommandListBuilder.

protected virtual void Generate(DropPrimaryKeyOperation operation, IModel model, MigrationCommandListBuilder builder, bool terminate = true)

Parameters

operation DropPrimaryKeyOperation

The operation.

model IModel

The target model which may be null if the operations exist without a model.

builder MigrationCommandListBuilder

The command builder to use to build the commands.

terminate bool

Indicates whether or not to terminate the command after generating SQL for the operation.

Generate(DropSchemaOperation, IModel, MigrationCommandListBuilder)

Builds commands for the given DropSchemaOperation by making calls on the given MigrationCommandListBuilder, and then terminates the final command.

protected virtual void Generate(DropSchemaOperation operation, IModel model, MigrationCommandListBuilder builder)

Parameters

operation DropSchemaOperation

The operation.

model IModel

The target model which may be null if the operations exist without a model.

builder MigrationCommandListBuilder

The command builder to use to build the commands.

Generate(DropSequenceOperation, IModel, MigrationCommandListBuilder)

Builds commands for the given DropSequenceOperation by making calls on the given MigrationCommandListBuilder, and then terminates the final command.

protected virtual void Generate(DropSequenceOperation operation, IModel model, MigrationCommandListBuilder builder)

Parameters

operation DropSequenceOperation

The operation.

model IModel

The target model which may be null if the operations exist without a model.

builder MigrationCommandListBuilder

The command builder to use to build the commands.

Generate(DropTableOperation, IModel, MigrationCommandListBuilder, bool)

Builds commands for the given DropTableOperation by making calls on the given MigrationCommandListBuilder.

protected virtual void Generate(DropTableOperation operation, IModel model, MigrationCommandListBuilder builder, bool terminate = true)

Parameters

operation DropTableOperation

The operation.

model IModel

The target model which may be null if the operations exist without a model.

builder MigrationCommandListBuilder

The command builder to use to build the commands.

terminate bool

Indicates whether or not to terminate the command after generating SQL for the operation.

Generate(DropUniqueConstraintOperation, IModel, MigrationCommandListBuilder)

Builds commands for the given DropUniqueConstraintOperation by making calls on the given MigrationCommandListBuilder, and then terminates the final command.

protected virtual void Generate(DropUniqueConstraintOperation operation, IModel model, MigrationCommandListBuilder builder)

Parameters

operation DropUniqueConstraintOperation

The operation.

model IModel

The target model which may be null if the operations exist without a model.

builder MigrationCommandListBuilder

The command builder to use to build the commands.

Generate(EnsureSchemaOperation, IModel, MigrationCommandListBuilder)

Can be overridden by database providers to build commands for the given EnsureSchemaOperation by making calls on the given MigrationCommandListBuilder.

Note that the default implementation of this method throws NotImplementedException. Providers must override if they are to support this kind of operation.

protected virtual void Generate(EnsureSchemaOperation operation, IModel model, MigrationCommandListBuilder builder)

Parameters

operation EnsureSchemaOperation

The operation.

model IModel

The target model which may be null if the operations exist without a model.

builder MigrationCommandListBuilder

The command builder to use to build the commands.

Generate(InsertDataOperation, IModel, MigrationCommandListBuilder, bool)

Builds commands for the given InsertDataOperation by making calls on the given MigrationCommandListBuilder.

protected virtual void Generate(InsertDataOperation operation, IModel model, MigrationCommandListBuilder builder, bool terminate = true)

Parameters

operation InsertDataOperation

The operation.

model IModel

The target model which may be null if the operations exist without a model.

builder MigrationCommandListBuilder

The command builder to use to build the commands.

terminate bool

Indicates whether or not to terminate the command after generating SQL for the operation.

Generate(MigrationOperation, IModel, MigrationCommandListBuilder)

Builds commands for the given MigrationOperation by making calls on the given MigrationCommandListBuilder.

This method uses a double-dispatch mechanism to call one of the 'Generate' methods that are specific to a certain subtype of MigrationOperation. Typically database providers will override these specific methods rather than this method. However, providers can override this methods to handle provider-specific operations.

protected virtual void Generate(MigrationOperation operation, IModel model, MigrationCommandListBuilder builder)

Parameters

operation MigrationOperation

The operation.

model IModel

The target model which may be null if the operations exist without a model.

builder MigrationCommandListBuilder

The command builder to use to build the commands.

Generate(RenameColumnOperation, IModel, MigrationCommandListBuilder)

Can be overridden by database providers to build commands for the given RenameColumnOperation by making calls on the given MigrationCommandListBuilder.

Note that the default implementation of this method throws NotImplementedException. Providers must override if they are to support this kind of operation.

protected virtual void Generate(RenameColumnOperation operation, IModel model, MigrationCommandListBuilder builder)

Parameters

operation RenameColumnOperation

The operation.

model IModel

The target model which may be null if the operations exist without a model.

builder MigrationCommandListBuilder

The command builder to use to build the commands.

Generate(RenameIndexOperation, IModel, MigrationCommandListBuilder)

Can be overridden by database providers to build commands for the given RenameIndexOperation by making calls on the given MigrationCommandListBuilder.

Note that the default implementation of this method throws NotImplementedException. Providers must override if they are to support this kind of operation.

protected virtual void Generate(RenameIndexOperation operation, IModel model, MigrationCommandListBuilder builder)

Parameters

operation RenameIndexOperation

The operation.

model IModel

The target model which may be null if the operations exist without a model.

builder MigrationCommandListBuilder

The command builder to use to build the commands.

Generate(RenameSequenceOperation, IModel, MigrationCommandListBuilder)

Can be overridden by database providers to build commands for the given RenameSequenceOperation by making calls on the given MigrationCommandListBuilder.

Note that the default implementation of this method throws NotImplementedException. Providers must override if they are to support this kind of operation.

protected virtual void Generate(RenameSequenceOperation operation, IModel model, MigrationCommandListBuilder builder)

Parameters

operation RenameSequenceOperation

The operation.

model IModel

The target model which may be null if the operations exist without a model.

builder MigrationCommandListBuilder

The command builder to use to build the commands.

Generate(RenameTableOperation, IModel, MigrationCommandListBuilder)

Can be overridden by database providers to build commands for the given RenameTableOperation by making calls on the given MigrationCommandListBuilder.

Note that the default implementation of this method throws NotImplementedException. Providers must override if they are to support this kind of operation.

protected virtual void Generate(RenameTableOperation operation, IModel model, MigrationCommandListBuilder builder)

Parameters

operation RenameTableOperation

The operation.

model IModel

The target model which may be null if the operations exist without a model.

builder MigrationCommandListBuilder

The command builder to use to build the commands.

Generate(RestartSequenceOperation, IModel, MigrationCommandListBuilder)

Builds commands for the given RestartSequenceOperation by making calls on the given MigrationCommandListBuilder, and then terminates the final command.

protected virtual void Generate(RestartSequenceOperation operation, IModel model, MigrationCommandListBuilder builder)

Parameters

operation RestartSequenceOperation

The operation.

model IModel

The target model which may be null if the operations exist without a model.

builder MigrationCommandListBuilder

The command builder to use to build the commands.

Generate(SqlOperation, IModel, MigrationCommandListBuilder)

Builds commands for the given SqlOperation by making calls on the given MigrationCommandListBuilder, and then terminates the final command.

protected virtual void Generate(SqlOperation operation, IModel model, MigrationCommandListBuilder builder)

Parameters

operation SqlOperation

The operation.

model IModel

The target model which may be null if the operations exist without a model.

builder MigrationCommandListBuilder

The command builder to use to build the commands.

Generate(UpdateDataOperation, IModel, MigrationCommandListBuilder)

Builds commands for the given UpdateDataOperation by making calls on the given MigrationCommandListBuilder, and then terminates the final command.

protected virtual void Generate(UpdateDataOperation operation, IModel model, MigrationCommandListBuilder builder)

Parameters

operation UpdateDataOperation

The operation.

model IModel

The target model which may be null if the operations exist without a model.

builder MigrationCommandListBuilder

The command builder to use to build the commands.

Generate(IReadOnlyList<MigrationOperation>, IModel, MigrationsSqlGenerationOptions)

Generates commands from a list of operations.

public virtual IReadOnlyList<MigrationCommand> Generate(IReadOnlyList<MigrationOperation> operations, IModel model = null, MigrationsSqlGenerationOptions options = MigrationsSqlGenerationOptions.Default)

Parameters

operations IReadOnlyList<MigrationOperation>

The operations.

model IModel

The target model which may be null if the operations exist without a model.

options MigrationsSqlGenerationOptions

The options to use when generating commands.

Returns

IReadOnlyList<MigrationCommand>

The list of commands to be executed or scripted.

GenerateModificationCommands(DeleteDataOperation, IModel)

Generates the commands that correspond to the given operation.

protected virtual IEnumerable<ModificationCommand> GenerateModificationCommands(DeleteDataOperation operation, IModel model)

Parameters

operation DeleteDataOperation

The data operation to generate commands for.

model IModel

The model.

Returns

IEnumerable<ModificationCommand>

The commands that correspond to the given operation.

GenerateModificationCommands(InsertDataOperation, IModel)

Generates the commands that correspond to the given operation.

protected virtual IEnumerable<ModificationCommand> GenerateModificationCommands(InsertDataOperation operation, IModel model)

Parameters

operation InsertDataOperation

The data operation to generate commands for.

model IModel

The model.

Returns

IEnumerable<ModificationCommand>

The commands that correspond to the given operation.

GenerateModificationCommands(UpdateDataOperation, IModel)

Generates the commands that correspond to the given operation.

protected virtual IEnumerable<ModificationCommand> GenerateModificationCommands(UpdateDataOperation operation, IModel model)

Parameters

operation UpdateDataOperation

The data operation to generate commands for.

model IModel

The model.

Returns

IEnumerable<ModificationCommand>

The commands that correspond to the given operation.

GetColumnType(string, string, string, ColumnOperation, IModel)

Gets the store/database type of a column given the provided metadata.

protected virtual string GetColumnType(string schema, string tableName, string name, ColumnOperation operation, IModel model)

Parameters

schema string

The schema that contains the table, or null to use the default schema.

tableName string

The table that contains the column.

name string

The column name.

operation ColumnOperation

The column metadata.

model IModel

The target model which may be null if the operations exist without a model.

Returns

string

The database/store type for the column.

HasLegacyRenameOperations(IModel)

Checks whether or not RenameTableOperation and RenameSequenceOperation use the legacy behavior of setting the new name and schema to null when unchanged.

protected virtual bool HasLegacyRenameOperations(IModel model)

Parameters

model IModel

The target model.

Returns

bool

true if the legacy behavior is used.

IndexOptions(CreateIndexOperation, IModel, MigrationCommandListBuilder)

Generates a SQL fragment for extras (filter, included columns, options) of an index from a CreateIndexOperation.

protected virtual void IndexOptions(CreateIndexOperation operation, IModel model, MigrationCommandListBuilder builder)

Parameters

operation CreateIndexOperation

The operation.

model IModel

The target model which may be null if the operations exist without a model.

builder MigrationCommandListBuilder

The command builder to use to add the SQL fragment.

IndexTraits(MigrationOperation, IModel, MigrationCommandListBuilder)

Generates a SQL fragment for traits of an index from a CreateIndexOperation, AddPrimaryKeyOperation, or AddUniqueConstraintOperation.

protected virtual void IndexTraits(MigrationOperation operation, IModel model, MigrationCommandListBuilder builder)

Parameters

operation MigrationOperation

The operation.

model IModel

The target model which may be null if the operations exist without a model.

builder MigrationCommandListBuilder

The command builder to use to add the SQL fragment.

IsOldColumnSupported(IModel)

Checks whether or not AddColumnOperation supports the passing in the old column, which was only added in EF Core 1.1.

protected virtual bool IsOldColumnSupported(IModel model)

Parameters

model IModel

The target model which may be null if the operations exist without a model.

Returns

bool

true If the model was generated by EF Core 1.1 or later; false if the model is null, has no version specified, or was generated by an EF Core version prior to 1.1.

PrimaryKeyConstraint(AddPrimaryKeyOperation, IModel, MigrationCommandListBuilder)

Generates a SQL fragment for a primary key constraint of an AddPrimaryKeyOperation.

protected virtual void PrimaryKeyConstraint(AddPrimaryKeyOperation operation, IModel model, MigrationCommandListBuilder builder)

Parameters

operation AddPrimaryKeyOperation

The operation.

model IModel

The target model which may be null if the operations exist without a model.

builder MigrationCommandListBuilder

The command builder to use to add the SQL fragment.

SequenceOptions(AlterSequenceOperation, IModel, MigrationCommandListBuilder)

Generates a SQL fragment configuring a sequence in a AlterSequenceOperation.

protected virtual void SequenceOptions(AlterSequenceOperation operation, IModel model, MigrationCommandListBuilder builder)

Parameters

operation AlterSequenceOperation

The operation.

model IModel

The target model which may be null if the operations exist without a model.

builder MigrationCommandListBuilder

The command builder to use to add the SQL fragment.

SequenceOptions(CreateSequenceOperation, IModel, MigrationCommandListBuilder)

Generates a SQL fragment configuring a sequence in a CreateSequenceOperation.

protected virtual void SequenceOptions(CreateSequenceOperation operation, IModel model, MigrationCommandListBuilder builder)

Parameters

operation CreateSequenceOperation

The operation.

model IModel

The target model which may be null if the operations exist without a model.

builder MigrationCommandListBuilder

The command builder to use to add the SQL fragment.

SequenceOptions(string, string, SequenceOperation, IModel, MigrationCommandListBuilder)

Generates a SQL fragment configuring a sequence with the given options.

protected virtual void SequenceOptions(string schema, string name, SequenceOperation operation, IModel model, MigrationCommandListBuilder builder)

Parameters

schema string

The schema that contains the sequence, or null to use the default schema.

name string

The sequence name.

operation SequenceOperation

The sequence options.

model IModel

The target model which may be null if the operations exist without a model.

builder MigrationCommandListBuilder

The command builder to use to add the SQL fragment.

TryGetVersion(IModel, out string)

Gets the product version used to generate the current migration. Providers can use this to preserve compatibility with migrations generated using previous versions.

protected virtual bool TryGetVersion(IModel model, out string version)

Parameters

model IModel

The target model.

version string

The version.

Returns

bool

true if the version could be retrieved.

UniqueConstraint(AddUniqueConstraintOperation, IModel, MigrationCommandListBuilder)

Generates a SQL fragment for a unique constraint of an AddUniqueConstraintOperation.

protected virtual void UniqueConstraint(AddUniqueConstraintOperation operation, IModel model, MigrationCommandListBuilder builder)

Parameters

operation AddUniqueConstraintOperation

The operation.

model IModel

The target model which may be null if the operations exist without a model.

builder MigrationCommandListBuilder

The command builder to use to add the SQL fragment.