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
dependenciesMigrationsSqlGeneratorDependenciesParameter object containing dependencies for this service.
Properties
Dependencies
Parameter object containing dependencies for this service.
protected virtual MigrationsSqlGeneratorDependencies Dependencies { get; }
Property Value
Options
Gets or sets the options to use when generating commands.
protected virtual MigrationsSqlGenerationOptions Options { get; set; }
Property Value
SqlGenerator
The IUpdateSqlGenerator.
protected virtual IUpdateSqlGenerator SqlGenerator { get; }
Property Value
VersionComparer
Gets a comparer that can be used to compare two product versions.
protected virtual IComparer<string> VersionComparer { get; }
Property Value
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
operationAddCheckConstraintOperationThe operation.
modelIModelThe target model which may be null if the operations exist without a model.
builderMigrationCommandListBuilderThe 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
operationAddColumnOperationThe operation.
modelIModelThe target model which may be null if the operations exist without a model.
builderMigrationCommandListBuilderThe 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
schemastringThe schema that contains the table, or null to use the default schema.
tablestringThe table that contains the column.
namestringThe column name.
operationColumnOperationThe column metadata.
modelIModelThe target model which may be null if the operations exist without a model.
builderMigrationCommandListBuilderThe 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
columnsstring[]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
schemastringThe schema that contains the table, or null to use the default schema.
tablestringThe table that contains the column.
namestringThe column name.
operationColumnOperationThe column metadata.
modelIModelThe target model which may be null if the operations exist without a model.
builderMigrationCommandListBuilderThe 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
operationCreateTableOperationThe operation.
modelIModelThe target model which may be null if the operations exist without a model.
builderMigrationCommandListBuilderThe 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
operationCreateTableOperationThe operation.
modelIModelThe target model which may be null if the operations exist without a model.
builderMigrationCommandListBuilderThe 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
operationCreateTableOperationThe operation.
modelIModelThe target model which may be null if the operations exist without a model.
builderMigrationCommandListBuilderThe 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
operationCreateTableOperationThe operation.
modelIModelThe target model which may be null if the operations exist without a model.
builderMigrationCommandListBuilderThe 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
operationCreateTableOperationThe operation.
modelIModelThe target model which may be null if the operations exist without a model.
builderMigrationCommandListBuilderThe 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
operationCreateTableOperationThe operation.
modelIModelThe target model which may be null if the operations exist without a model.
builderMigrationCommandListBuilderThe 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
defaultValueobjectThe default value for the column.
defaultValueSqlstringThe SQL expression to use for the column's default constraint.
columnTypestringStore/database type of the column.
builderMigrationCommandListBuilderThe 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
builderMigrationCommandListBuilderThe command builder to use to add the SQL fragment.
suppressTransactionboolIndicates 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
modelIModelThe target model which may be null if the operations exist without a model.
schemastringThe schema that contains the table, or null to use the default schema.
tableNamestringThe 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
modelIModelThe target model which may be null if the operations exist without a model.
schemastringThe schema that contains the table, or null to use the default schema.
tableNamestringThe name of the table that contains the column.
columnNamestringThe 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
referentialActionReferentialActionThe referential action.
builderMigrationCommandListBuilderThe 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
operationAddForeignKeyOperationThe operation.
modelIModelThe target model which may be null if the operations exist without a model.
builderMigrationCommandListBuilderThe 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
operationAddCheckConstraintOperationThe operation.
modelIModelThe target model which may be null if the operations exist without a model.
builderMigrationCommandListBuilderThe 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
operationAddColumnOperationThe operation.
modelIModelThe target model which may be null if the operations exist without a model.
builderMigrationCommandListBuilderThe command builder to use to build the commands.
terminateboolIndicates 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
operationAddForeignKeyOperationThe operation.
modelIModelThe target model which may be null if the operations exist without a model.
builderMigrationCommandListBuilderThe command builder to use to build the commands.
terminateboolIndicates 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
operationAddPrimaryKeyOperationThe operation.
modelIModelThe target model which may be null if the operations exist without a model.
builderMigrationCommandListBuilderThe command builder to use to build the commands.
terminateboolIndicates 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
operationAddUniqueConstraintOperationThe operation.
modelIModelThe target model which may be null if the operations exist without a model.
builderMigrationCommandListBuilderThe 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
operationAlterColumnOperationThe operation.
modelIModelThe target model which may be null if the operations exist without a model.
builderMigrationCommandListBuilderThe 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
operationAlterDatabaseOperationThe operation.
modelIModelThe target model which may be null if the operations exist without a model.
builderMigrationCommandListBuilderThe 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
operationAlterSequenceOperationThe operation.
modelIModelThe target model which may be null if the operations exist without a model.
builderMigrationCommandListBuilderThe 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
operationAlterTableOperationThe operation.
modelIModelThe target model which may be null if the operations exist without a model.
builderMigrationCommandListBuilderThe 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
operationCreateIndexOperationThe operation.
modelIModelThe target model which may be null if the operations exist without a model.
builderMigrationCommandListBuilderThe command builder to use to build the commands.
terminateboolIndicates 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
operationCreateSequenceOperationThe operation.
modelIModelThe target model which may be null if the operations exist without a model.
builderMigrationCommandListBuilderThe 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
operationCreateTableOperationThe operation.
modelIModelThe target model which may be null if the operations exist without a model.
builderMigrationCommandListBuilderThe command builder to use to build the commands.
terminateboolIndicates 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
operationDeleteDataOperationThe operation.
modelIModelThe target model which may be null if the operations exist without a model.
builderMigrationCommandListBuilderThe 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
operationDropCheckConstraintOperationThe operation.
modelIModelThe target model which may be null if the operations exist without a model.
builderMigrationCommandListBuilderThe 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
operationDropColumnOperationThe operation.
modelIModelThe target model which may be null if the operations exist without a model.
builderMigrationCommandListBuilderThe command builder to use to build the commands.
terminateboolIndicates 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
operationDropForeignKeyOperationThe operation.
modelIModelThe target model which may be null if the operations exist without a model.
builderMigrationCommandListBuilderThe command builder to use to build the commands.
terminateboolIndicates 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
operationDropIndexOperationThe operation.
modelIModelThe target model which may be null if the operations exist without a model.
builderMigrationCommandListBuilderThe command builder to use to build the commands.
terminateboolIndicates 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
operationDropPrimaryKeyOperationThe operation.
modelIModelThe target model which may be null if the operations exist without a model.
builderMigrationCommandListBuilderThe command builder to use to build the commands.
terminateboolIndicates 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
operationDropSchemaOperationThe operation.
modelIModelThe target model which may be null if the operations exist without a model.
builderMigrationCommandListBuilderThe 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
operationDropSequenceOperationThe operation.
modelIModelThe target model which may be null if the operations exist without a model.
builderMigrationCommandListBuilderThe 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
operationDropTableOperationThe operation.
modelIModelThe target model which may be null if the operations exist without a model.
builderMigrationCommandListBuilderThe command builder to use to build the commands.
terminateboolIndicates 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
operationDropUniqueConstraintOperationThe operation.
modelIModelThe target model which may be null if the operations exist without a model.
builderMigrationCommandListBuilderThe 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
operationEnsureSchemaOperationThe operation.
modelIModelThe target model which may be null if the operations exist without a model.
builderMigrationCommandListBuilderThe 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
operationInsertDataOperationThe operation.
modelIModelThe target model which may be null if the operations exist without a model.
builderMigrationCommandListBuilderThe command builder to use to build the commands.
terminateboolIndicates 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
operationMigrationOperationThe operation.
modelIModelThe target model which may be null if the operations exist without a model.
builderMigrationCommandListBuilderThe 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
operationRenameColumnOperationThe operation.
modelIModelThe target model which may be null if the operations exist without a model.
builderMigrationCommandListBuilderThe 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
operationRenameIndexOperationThe operation.
modelIModelThe target model which may be null if the operations exist without a model.
builderMigrationCommandListBuilderThe 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
operationRenameSequenceOperationThe operation.
modelIModelThe target model which may be null if the operations exist without a model.
builderMigrationCommandListBuilderThe 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
operationRenameTableOperationThe operation.
modelIModelThe target model which may be null if the operations exist without a model.
builderMigrationCommandListBuilderThe 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
operationRestartSequenceOperationThe operation.
modelIModelThe target model which may be null if the operations exist without a model.
builderMigrationCommandListBuilderThe 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
operationSqlOperationThe operation.
modelIModelThe target model which may be null if the operations exist without a model.
builderMigrationCommandListBuilderThe 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
operationUpdateDataOperationThe operation.
modelIModelThe target model which may be null if the operations exist without a model.
builderMigrationCommandListBuilderThe 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
operationsIReadOnlyList<MigrationOperation>The operations.
modelIModelThe target model which may be null if the operations exist without a model.
optionsMigrationsSqlGenerationOptionsThe 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
operationDeleteDataOperationThe data operation to generate commands for.
modelIModelThe 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
operationInsertDataOperationThe data operation to generate commands for.
modelIModelThe 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
operationUpdateDataOperationThe data operation to generate commands for.
modelIModelThe 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
schemastringThe schema that contains the table, or null to use the default schema.
tableNamestringThe table that contains the column.
namestringThe column name.
operationColumnOperationThe column metadata.
modelIModelThe 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
modelIModelThe target model.
Returns
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
operationCreateIndexOperationThe operation.
modelIModelThe target model which may be null if the operations exist without a model.
builderMigrationCommandListBuilderThe 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
operationMigrationOperationThe operation.
modelIModelThe target model which may be null if the operations exist without a model.
builderMigrationCommandListBuilderThe 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
modelIModelThe 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
operationAddPrimaryKeyOperationThe operation.
modelIModelThe target model which may be null if the operations exist without a model.
builderMigrationCommandListBuilderThe 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
operationAlterSequenceOperationThe operation.
modelIModelThe target model which may be null if the operations exist without a model.
builderMigrationCommandListBuilderThe 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
operationCreateSequenceOperationThe operation.
modelIModelThe target model which may be null if the operations exist without a model.
builderMigrationCommandListBuilderThe 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
schemastringThe schema that contains the sequence, or null to use the default schema.
namestringThe sequence name.
operationSequenceOperationThe sequence options.
modelIModelThe target model which may be null if the operations exist without a model.
builderMigrationCommandListBuilderThe 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
modelIModelThe target model.
versionstringThe version.
Returns
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
operationAddUniqueConstraintOperationThe operation.
modelIModelThe target model which may be null if the operations exist without a model.
builderMigrationCommandListBuilderThe command builder to use to add the SQL fragment.