MigrationsSqlGenerator Class

Definition

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

public class MigrationsSqlGenerator : Microsoft.EntityFrameworkCore.Migrations.IMigrationsSqlGenerator
type MigrationsSqlGenerator = class
    interface IMigrationsSqlGenerator
Public Class MigrationsSqlGenerator
Implements IMigrationsSqlGenerator
Inheritance
MigrationsSqlGenerator
Derived
Implements

Remarks

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

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

See Database migrations for more information and examples.

Constructors

MigrationsSqlGenerator(IRelationalCommandBuilderFactory, ISqlGenerationHelper, IRelationalTypeMapper, IRelationalAnnotationProvider)
MigrationsSqlGenerator(MigrationsSqlGeneratorDependencies)

Creates a new MigrationsSqlGenerator instance using the given dependencies.

Properties

Annotations
Dependencies

Relational provider-specific dependencies for this service.

Options

Gets or sets the options to use when generating commands.

SqlGenerationHelper
SqlGenerator

The IUpdateSqlGenerator.

TypeMapper
VersionComparer

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

Methods

CheckConstraint(AddCheckConstraintOperation, IModel, MigrationCommandListBuilder)

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

CheckConstraint(CreateCheckConstraintOperation, IModel, MigrationCommandListBuilder)

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

ColumnDefinition(AddColumnOperation, IModel, MigrationCommandListBuilder)

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

ColumnDefinition(String, String, String, ColumnOperation, IModel, MigrationCommandListBuilder)

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

ColumnDefinition(String, String, String, Type, String, Nullable<Boolean>, Nullable<Int32>, Boolean, Boolean, Object, String, String, IAnnotatable, IModel, MigrationCommandListBuilder)

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

ColumnDefinition(String, String, String, Type, String, Nullable<Boolean>, Nullable<Int32>, Nullable<Boolean>, Boolean, Boolean, Object, String, String, IAnnotatable, IModel, MigrationCommandListBuilder)

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

ColumnList(String[])

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

ComputedColumnDefinition(String, String, String, ColumnOperation, IModel, MigrationCommandListBuilder)

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

CreateTableCheckConstraints(CreateTableOperation, IModel, MigrationCommandListBuilder)

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

CreateTableColumns(CreateTableOperation, IModel, MigrationCommandListBuilder)

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

CreateTableConstraints(CreateTableOperation, IModel, MigrationCommandListBuilder)

Generates a SQL fragment for the constraints of a CreateTableOperation.

CreateTableForeignKeys(CreateTableOperation, IModel, MigrationCommandListBuilder)

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

CreateTablePrimaryKeyConstraint(CreateTableOperation, IModel, MigrationCommandListBuilder)

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

CreateTableUniqueConstraints(CreateTableOperation, IModel, MigrationCommandListBuilder)

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

DefaultValue(Object, String, MigrationCommandListBuilder)

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

DefaultValue(Object, String, String, MigrationCommandListBuilder)

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

EndStatement(MigrationCommandListBuilder, Boolean)

Generates a SQL fragment to terminate the SQL command.

FindEntityTypes(IModel, String, String)
Obsolete.

Finds all IEntityTypes that are mapped to the given table.

FindProperty(IModel, String, String, String)
Obsolete.

Finds some 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.

ForeignKeyAction(ReferentialAction, MigrationCommandListBuilder)

Generates a SQL fragment for the given referential action.

ForeignKeyConstraint(AddForeignKeyOperation, IModel, MigrationCommandListBuilder)

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

Generate(AddCheckConstraintOperation, IModel, MigrationCommandListBuilder)

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

Generate(AddColumnOperation, IModel, MigrationCommandListBuilder, Boolean)

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

Generate(AddColumnOperation, IModel, MigrationCommandListBuilder)

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

Generate(AddForeignKeyOperation, IModel, MigrationCommandListBuilder, Boolean)

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

Generate(AddForeignKeyOperation, IModel, MigrationCommandListBuilder)

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

Generate(AddPrimaryKeyOperation, IModel, MigrationCommandListBuilder, Boolean)

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

Generate(AddPrimaryKeyOperation, IModel, MigrationCommandListBuilder)

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

Generate(AddUniqueConstraintOperation, IModel, MigrationCommandListBuilder)

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

Generate(AlterColumnOperation, IModel, MigrationCommandListBuilder)

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

Generate(AlterDatabaseOperation, IModel, MigrationCommandListBuilder)

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

Generate(AlterSequenceOperation, IModel, MigrationCommandListBuilder)

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

Generate(AlterTableOperation, IModel, MigrationCommandListBuilder)

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

Generate(CreateCheckConstraintOperation, IModel, MigrationCommandListBuilder)

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

Generate(CreateIndexOperation, IModel, MigrationCommandListBuilder, Boolean)

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

Generate(CreateIndexOperation, IModel, MigrationCommandListBuilder)

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

Generate(CreateSequenceOperation, IModel, MigrationCommandListBuilder)

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

Generate(CreateTableOperation, IModel, MigrationCommandListBuilder, Boolean)

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

Generate(CreateTableOperation, IModel, MigrationCommandListBuilder)

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

Generate(DeleteDataOperation, IModel, MigrationCommandListBuilder)

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

Generate(DropCheckConstraintOperation, IModel, MigrationCommandListBuilder)

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

Generate(DropColumnOperation, IModel, MigrationCommandListBuilder, Boolean)

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

Generate(DropColumnOperation, IModel, MigrationCommandListBuilder)

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

Generate(DropForeignKeyOperation, IModel, MigrationCommandListBuilder, Boolean)

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

Generate(DropForeignKeyOperation, IModel, MigrationCommandListBuilder)

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

Generate(DropIndexOperation, IModel, MigrationCommandListBuilder, Boolean)

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

Generate(DropIndexOperation, IModel, MigrationCommandListBuilder)

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.

Generate(DropPrimaryKeyOperation, IModel, MigrationCommandListBuilder, Boolean)

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

Generate(DropPrimaryKeyOperation, IModel, MigrationCommandListBuilder)

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

Generate(DropSchemaOperation, IModel, MigrationCommandListBuilder)

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

Generate(DropSequenceOperation, IModel, MigrationCommandListBuilder)

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

Generate(DropTableOperation, IModel, MigrationCommandListBuilder, Boolean)

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

Generate(DropTableOperation, IModel, MigrationCommandListBuilder)

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

Generate(DropUniqueConstraintOperation, IModel, MigrationCommandListBuilder)

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

Generate(EnsureSchemaOperation, IModel, MigrationCommandListBuilder)

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

Generate(InsertDataOperation, IModel, MigrationCommandListBuilder, Boolean)

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

Generate(InsertDataOperation, IModel, MigrationCommandListBuilder)

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

Generate(IReadOnlyList<MigrationOperation>, IModel, MigrationsSqlGenerationOptions)

Generates commands from a list of operations.

Generate(IReadOnlyList<MigrationOperation>, IModel)

Generates commands from a list of operations.

Generate(MigrationOperation, IModel, MigrationCommandListBuilder)

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

Generate(RenameColumnOperation, IModel, MigrationCommandListBuilder)

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

Generate(RenameIndexOperation, IModel, MigrationCommandListBuilder)

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

Generate(RenameSequenceOperation, IModel, MigrationCommandListBuilder)

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

Generate(RenameTableOperation, IModel, MigrationCommandListBuilder)

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

Generate(RestartSequenceOperation, IModel, MigrationCommandListBuilder)

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

Generate(SqlOperation, IModel, MigrationCommandListBuilder)

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

Generate(UpdateDataOperation, IModel, MigrationCommandListBuilder)

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

GenerateIndexColumnList(CreateIndexOperation, IModel, MigrationCommandListBuilder)

Returns a SQL fragment for the column list of an index from a CreateIndexOperation.

GenerateModificationCommands(DeleteDataOperation, IModel)

Generates the commands that correspond to the given operation.

GenerateModificationCommands(InsertDataOperation, IModel)

Generates the commands that correspond to the given operation.

GenerateModificationCommands(UpdateDataOperation, IModel)

Generates 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.

GetColumnType(String, String, String, Type, Nullable<Boolean>, Nullable<Int32>, Boolean, IModel)

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

GetColumnType(String, String, String, Type, Nullable<Boolean>, Nullable<Int32>, Nullable<Boolean>, Boolean, IModel)

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

HasLegacyRenameOperations(IModel)

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

IndexOptions(CreateIndexOperation, IModel, MigrationCommandListBuilder)

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

IndexOptions(MigrationOperation, IModel, MigrationCommandListBuilder)

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

IndexTraits(MigrationOperation, IModel, MigrationCommandListBuilder)

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

IsOldColumnSupported(IModel)

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

PrimaryKeyConstraint(AddPrimaryKeyOperation, IModel, MigrationCommandListBuilder)

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

SequenceOptions(AlterSequenceOperation, IModel, MigrationCommandListBuilder)

Generates a SQL fragment configuring a sequence in a AlterSequenceOperation.

SequenceOptions(CreateSequenceOperation, IModel, MigrationCommandListBuilder)

Generates a SQL fragment configuring a sequence in a CreateSequenceOperation.

SequenceOptions(String, String, Int32, Nullable<Int64>, Nullable<Int64>, Boolean, IModel, MigrationCommandListBuilder)

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

SequenceOptions(String, String, SequenceOperation, IModel, MigrationCommandListBuilder, Boolean)

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

SequenceOptions(String, String, SequenceOperation, IModel, MigrationCommandListBuilder)

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

TryGetVersion(IModel, String)

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

UniqueConstraint(AddUniqueConstraintOperation, IModel, MigrationCommandListBuilder)

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

Applies to