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.
public class MigrationsSqlGenerator : IMigrationsSqlGenerator
- Inheritance
-
MigrationsSqlGenerator
- Implements
- Inherited Members
Remarks
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.
See Database migrations for more information and examples.
Constructors
MigrationsSqlGenerator(MigrationsSqlGeneratorDependencies)
Creates a new MigrationsSqlGenerator instance using the given dependencies.
public MigrationsSqlGenerator(MigrationsSqlGeneratorDependencies dependencies)
Parameters
dependencies
MigrationsSqlGeneratorDependenciesParameter object containing dependencies for this service.
Properties
Dependencies
Relational provider-specific 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
operation
AddCheckConstraintOperationThe operation.
model
IModelThe target model which may be null if the operations exist without a model.
builder
MigrationCommandListBuilderThe 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
AddColumnOperationThe operation.
model
IModelThe target model which may be null if the operations exist without a model.
builder
MigrationCommandListBuilderThe 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
stringThe schema that contains the table, or null to use the default schema.
table
stringThe table that contains the column.
name
stringThe column name.
operation
ColumnOperationThe column metadata.
model
IModelThe target model which may be null if the operations exist without a model.
builder
MigrationCommandListBuilderThe 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
stringThe schema that contains the table, or null to use the default schema.
table
stringThe table that contains the column.
name
stringThe column name.
operation
ColumnOperationThe column metadata.
model
IModelThe target model which may be null if the operations exist without a model.
builder
MigrationCommandListBuilderThe 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
CreateTableOperationThe operation.
model
IModelThe target model which may be null if the operations exist without a model.
builder
MigrationCommandListBuilderThe command builder to use to add the SQL fragment.
CreateTableColumns(CreateTableOperation, IModel?, MigrationCommandListBuilder)
Generates a SQL fragment for the column definitions in a CreateTableOperation.
protected virtual void CreateTableColumns(CreateTableOperation operation, IModel? model, MigrationCommandListBuilder builder)
Parameters
operation
CreateTableOperationThe operation.
model
IModelThe target model which may be null if the operations exist without a model.
builder
MigrationCommandListBuilderThe 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
CreateTableOperationThe operation.
model
IModelThe target model which may be null if the operations exist without a model.
builder
MigrationCommandListBuilderThe 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
CreateTableOperationThe operation.
model
IModelThe target model which may be null if the operations exist without a model.
builder
MigrationCommandListBuilderThe 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
CreateTableOperationThe operation.
model
IModelThe target model which may be null if the operations exist without a model.
builder
MigrationCommandListBuilderThe 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
CreateTableOperationThe operation.
model
IModelThe target model which may be null if the operations exist without a model.
builder
MigrationCommandListBuilderThe 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
objectThe default value for the column.
defaultValueSql
stringThe SQL expression to use for the column's default constraint.
columnType
stringStore/database type of the column.
builder
MigrationCommandListBuilderThe 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
MigrationCommandListBuilderThe command builder to use to add the SQL fragment.
suppressTransaction
boolIndicates whether or not transactions should be suppressed while executing the built command.
ForeignKeyAction(ReferentialAction, MigrationCommandListBuilder)
Generates a SQL fragment for the given referential action.
protected virtual void ForeignKeyAction(ReferentialAction referentialAction, MigrationCommandListBuilder builder)
Parameters
referentialAction
ReferentialActionThe referential action.
builder
MigrationCommandListBuilderThe 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
AddForeignKeyOperationThe operation.
model
IModelThe target model which may be null if the operations exist without a model.
builder
MigrationCommandListBuilderThe 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
AddCheckConstraintOperationThe operation.
model
IModelThe target model which may be null if the operations exist without a model.
builder
MigrationCommandListBuilderThe 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
AddColumnOperationThe operation.
model
IModelThe target model which may be null if the operations exist without a model.
builder
MigrationCommandListBuilderThe command builder to use to build the commands.
terminate
boolIndicates 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
AddForeignKeyOperationThe operation.
model
IModelThe target model which may be null if the operations exist without a model.
builder
MigrationCommandListBuilderThe command builder to use to build the commands.
terminate
boolIndicates 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
AddPrimaryKeyOperationThe operation.
model
IModelThe target model which may be null if the operations exist without a model.
builder
MigrationCommandListBuilderThe command builder to use to build the commands.
terminate
boolIndicates 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
AddUniqueConstraintOperationThe operation.
model
IModelThe target model which may be null if the operations exist without a model.
builder
MigrationCommandListBuilderThe 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.
protected virtual void Generate(AlterColumnOperation operation, IModel? model, MigrationCommandListBuilder builder)
Parameters
operation
AlterColumnOperationThe operation.
model
IModelThe target model which may be null if the operations exist without a model.
builder
MigrationCommandListBuilderThe command builder to use to build the commands.
Remarks
Note that the default implementation of this method throws NotSupportedException. Providers must override if they are to support this kind of operation.
Generate(AlterDatabaseOperation, IModel?, MigrationCommandListBuilder)
Can be overridden by database providers to build commands for the given AlterDatabaseOperation by making calls on the given MigrationCommandListBuilder.
protected virtual void Generate(AlterDatabaseOperation operation, IModel? model, MigrationCommandListBuilder builder)
Parameters
operation
AlterDatabaseOperationThe operation.
model
IModelThe target model which may be null if the operations exist without a model.
builder
MigrationCommandListBuilderThe command builder to use to build the commands.
Remarks
Note that there is no default implementation of this method. Providers must override if they are to support this kind of operation.
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
AlterSequenceOperationThe operation.
model
IModelThe target model which may be null if the operations exist without a model.
builder
MigrationCommandListBuilderThe 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.
protected virtual void Generate(AlterTableOperation operation, IModel? model, MigrationCommandListBuilder builder)
Parameters
operation
AlterTableOperationThe operation.
model
IModelThe target model which may be null if the operations exist without a model.
builder
MigrationCommandListBuilderThe command builder to use to build the commands.
Remarks
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.
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
CreateIndexOperationThe operation.
model
IModelThe target model which may be null if the operations exist without a model.
builder
MigrationCommandListBuilderThe command builder to use to build the commands.
terminate
boolIndicates 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
CreateSequenceOperationThe operation.
model
IModelThe target model which may be null if the operations exist without a model.
builder
MigrationCommandListBuilderThe 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
CreateTableOperationThe operation.
model
IModelThe target model which may be null if the operations exist without a model.
builder
MigrationCommandListBuilderThe command builder to use to build the commands.
terminate
boolIndicates 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
DeleteDataOperationThe operation.
model
IModelThe target model which may be null if the operations exist without a model.
builder
MigrationCommandListBuilderThe 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
DropCheckConstraintOperationThe operation.
model
IModelThe target model which may be null if the operations exist without a model.
builder
MigrationCommandListBuilderThe 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
DropColumnOperationThe operation.
model
IModelThe target model which may be null if the operations exist without a model.
builder
MigrationCommandListBuilderThe command builder to use to build the commands.
terminate
boolIndicates 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
DropForeignKeyOperationThe operation.
model
IModelThe target model which may be null if the operations exist without a model.
builder
MigrationCommandListBuilderThe command builder to use to build the commands.
terminate
boolIndicates 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.
protected virtual void Generate(DropIndexOperation operation, IModel? model, MigrationCommandListBuilder builder, bool terminate = true)
Parameters
operation
DropIndexOperationThe operation.
model
IModelThe target model which may be null if the operations exist without a model.
builder
MigrationCommandListBuilderThe command builder to use to build the commands.
terminate
boolIndicates whether or not to terminate the command after generating SQL for the operation.
Remarks
Note that the default implementation of this method throws NotSupportedException. Providers must override if they are to support this kind of 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
DropPrimaryKeyOperationThe operation.
model
IModelThe target model which may be null if the operations exist without a model.
builder
MigrationCommandListBuilderThe command builder to use to build the commands.
terminate
boolIndicates 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
DropSchemaOperationThe operation.
model
IModelThe target model which may be null if the operations exist without a model.
builder
MigrationCommandListBuilderThe 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
DropSequenceOperationThe operation.
model
IModelThe target model which may be null if the operations exist without a model.
builder
MigrationCommandListBuilderThe 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
DropTableOperationThe operation.
model
IModelThe target model which may be null if the operations exist without a model.
builder
MigrationCommandListBuilderThe command builder to use to build the commands.
terminate
boolIndicates 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
DropUniqueConstraintOperationThe operation.
model
IModelThe target model which may be null if the operations exist without a model.
builder
MigrationCommandListBuilderThe 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.
protected virtual void Generate(EnsureSchemaOperation operation, IModel? model, MigrationCommandListBuilder builder)
Parameters
operation
EnsureSchemaOperationThe operation.
model
IModelThe target model which may be null if the operations exist without a model.
builder
MigrationCommandListBuilderThe command builder to use to build the commands.
Remarks
Note that the default implementation of this method throws NotSupportedException. Providers must override if they are to support this kind of operation.
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
InsertDataOperationThe operation.
model
IModelThe target model which may be null if the operations exist without a model.
builder
MigrationCommandListBuilderThe command builder to use to build the commands.
terminate
boolIndicates 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.
protected virtual void Generate(MigrationOperation operation, IModel? model, MigrationCommandListBuilder builder)
Parameters
operation
MigrationOperationThe operation.
model
IModelThe target model which may be null if the operations exist without a model.
builder
MigrationCommandListBuilderThe command builder to use to build the commands.
Remarks
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.
Generate(RenameColumnOperation, IModel?, MigrationCommandListBuilder)
Can be overridden by database providers to build commands for the given RenameColumnOperation by making calls on the given MigrationCommandListBuilder.
protected virtual void Generate(RenameColumnOperation operation, IModel? model, MigrationCommandListBuilder builder)
Parameters
operation
RenameColumnOperationThe operation.
model
IModelThe target model which may be null if the operations exist without a model.
builder
MigrationCommandListBuilderThe command builder to use to build the commands.
Remarks
Note that the default implementation of this method throws NotSupportedException. Providers must override if they are to support this kind of operation.
Generate(RenameIndexOperation, IModel?, MigrationCommandListBuilder)
Can be overridden by database providers to build commands for the given RenameIndexOperation by making calls on the given MigrationCommandListBuilder.
protected virtual void Generate(RenameIndexOperation operation, IModel? model, MigrationCommandListBuilder builder)
Parameters
operation
RenameIndexOperationThe operation.
model
IModelThe target model which may be null if the operations exist without a model.
builder
MigrationCommandListBuilderThe command builder to use to build the commands.
Remarks
Note that the default implementation of this method throws NotSupportedException. Providers must override if they are to support this kind of operation.
Generate(RenameSequenceOperation, IModel?, MigrationCommandListBuilder)
Can be overridden by database providers to build commands for the given RenameSequenceOperation by making calls on the given MigrationCommandListBuilder.
protected virtual void Generate(RenameSequenceOperation operation, IModel? model, MigrationCommandListBuilder builder)
Parameters
operation
RenameSequenceOperationThe operation.
model
IModelThe target model which may be null if the operations exist without a model.
builder
MigrationCommandListBuilderThe command builder to use to build the commands.
Remarks
Note that the default implementation of this method throws NotSupportedException. Providers must override if they are to support this kind of operation.
Generate(RenameTableOperation, IModel?, MigrationCommandListBuilder)
Can be overridden by database providers to build commands for the given RenameTableOperation by making calls on the given MigrationCommandListBuilder.
protected virtual void Generate(RenameTableOperation operation, IModel? model, MigrationCommandListBuilder builder)
Parameters
operation
RenameTableOperationThe operation.
model
IModelThe target model which may be null if the operations exist without a model.
builder
MigrationCommandListBuilderThe command builder to use to build the commands.
Remarks
Note that the default implementation of this method throws NotSupportedException. Providers must override if they are to support this kind of operation.
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
RestartSequenceOperationThe operation.
model
IModelThe target model which may be null if the operations exist without a model.
builder
MigrationCommandListBuilderThe 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
SqlOperationThe operation.
model
IModelThe target model which may be null if the operations exist without a model.
builder
MigrationCommandListBuilderThe 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
UpdateDataOperationThe operation.
model
IModelThe target model which may be null if the operations exist without a model.
builder
MigrationCommandListBuilderThe 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
IModelThe target model which may be null if the operations exist without a model.
options
MigrationsSqlGenerationOptionsThe options to use when generating commands.
Returns
- IReadOnlyList<MigrationCommand>
The list of commands to be executed or scripted.
GenerateIndexColumnList(CreateIndexOperation, IModel?, MigrationCommandListBuilder)
Returns a SQL fragment for the column list of an index from a CreateIndexOperation.
protected virtual void GenerateIndexColumnList(CreateIndexOperation operation, IModel? model, MigrationCommandListBuilder builder)
Parameters
operation
CreateIndexOperationThe operation.
model
IModelThe target model which may be null if the operations exist without a model.
builder
MigrationCommandListBuilderThe command builder to use to add the SQL fragment.
GenerateModificationCommands(DeleteDataOperation, IModel?)
Generates the commands that correspond to the given operation.
protected virtual IEnumerable<IReadOnlyModificationCommand> GenerateModificationCommands(DeleteDataOperation operation, IModel? model)
Parameters
operation
DeleteDataOperationThe data operation to generate commands for.
model
IModelThe model.
Returns
- IEnumerable<IReadOnlyModificationCommand>
The commands that correspond to the given operation.
GenerateModificationCommands(InsertDataOperation, IModel?)
Generates the commands that correspond to the given operation.
protected virtual IEnumerable<IReadOnlyModificationCommand> GenerateModificationCommands(InsertDataOperation operation, IModel? model)
Parameters
operation
InsertDataOperationThe data operation to generate commands for.
model
IModelThe model.
Returns
- IEnumerable<IReadOnlyModificationCommand>
The commands that correspond to the given operation.
GenerateModificationCommands(UpdateDataOperation, IModel?)
Generates the commands that correspond to the given operation.
protected virtual IEnumerable<IReadOnlyModificationCommand> GenerateModificationCommands(UpdateDataOperation operation, IModel? model)
Parameters
operation
UpdateDataOperationThe data operation to generate commands for.
model
IModelThe model.
Returns
- IEnumerable<IReadOnlyModificationCommand>
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
stringThe schema that contains the table, or null to use the default schema.
tableName
stringThe table that contains the column.
name
stringThe column name.
operation
ColumnOperationThe column metadata.
model
IModelThe 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
IModelThe 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
operation
CreateIndexOperationThe operation.
model
IModelThe target model which may be null if the operations exist without a model.
builder
MigrationCommandListBuilderThe 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
MigrationOperationThe operation.
model
IModelThe target model which may be null if the operations exist without a model.
builder
MigrationCommandListBuilderThe 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
IModelThe 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
AddPrimaryKeyOperationThe operation.
model
IModelThe target model which may be null if the operations exist without a model.
builder
MigrationCommandListBuilderThe 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
AlterSequenceOperationThe operation.
model
IModelThe target model which may be null if the operations exist without a model.
builder
MigrationCommandListBuilderThe 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
CreateSequenceOperationThe operation.
model
IModelThe target model which may be null if the operations exist without a model.
builder
MigrationCommandListBuilderThe 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
stringThe schema that contains the sequence, or null to use the default schema.
name
stringThe sequence name.
operation
SequenceOperationThe sequence options.
model
IModelThe target model which may be null if the operations exist without a model.
builder
MigrationCommandListBuilderThe 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
IModelThe target model.
version
stringThe 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
operation
AddUniqueConstraintOperationThe operation.
model
IModelThe target model which may be null if the operations exist without a model.
builder
MigrationCommandListBuilderThe command builder to use to add the SQL fragment.