Class MigrationBuilder
- Namespace
- Microsoft.EntityFrameworkCore.Migrations
- Assembly
- Microsoft.EntityFrameworkCore.Relational.dll
A builder providing a fluent-like API for building MigrationOperations.
public class MigrationBuilder
- Inheritance
-
MigrationBuilder
- Inherited Members
Remarks
See Database migrations for more information and examples.
Constructors
MigrationBuilder(string?)
Creates a new instance of the builder.
public MigrationBuilder(string? activeProvider)
Parameters
activeProviderstringThe name of the database provider being used.
Properties
ActiveProvider
The name of the database provider being used.
public virtual string? ActiveProvider { get; }
Property Value
Operations
The list of MigrationOperations being built.
public virtual List<MigrationOperation> Operations { get; }
Property Value
Methods
AddCheckConstraint(string, string, string, string?)
Builds an AddCheckConstraintOperation to add a new check constraint to a table.
public virtual OperationBuilder<AddCheckConstraintOperation> AddCheckConstraint(string name, string table, string sql, string? schema = null)
Parameters
namestringThe check constraint name.
tablestringThe name of the table for the check constraint.
sqlstringThe constraint sql for the check constraint.
schemastringThe schema that contains the check constraint, or null to use the default schema.
Returns
- OperationBuilder<AddCheckConstraintOperation>
A builder to allow annotations to be added to the operation.
Remarks
See Database migrations for more information and examples.
AddColumn<T>(string, string, string?, bool?, int?, bool, string?, bool, object?, string?, string?, bool?, string?, string?, int?, int?, bool?)
Builds an AddColumnOperation to add a new column to a table.
public virtual OperationBuilder<AddColumnOperation> AddColumn<T>(string name, string table, string? type = null, bool? unicode = null, int? maxLength = null, bool rowVersion = false, string? schema = null, bool nullable = false, object? defaultValue = null, string? defaultValueSql = null, string? computedColumnSql = null, bool? fixedLength = null, string? comment = null, string? collation = null, int? precision = null, int? scale = null, bool? stored = null)
Parameters
namestringThe column name.
tablestringThe name of the table that contains the column.
typestringThe store/database type of the column.
unicodebool?Indicates whether or not the column can contain Unicode data, or null if not specified or not applicable.
maxLengthint?The maximum length of data that can be stored in the column, or null if not specified or not applicable.
rowVersionboolIndicates whether or not the column acts as an automatic concurrency token, such as a rowversion/timestamp column in SQL Server.
schemastringThe schema that contains the table, or null if the default schema should be used.
nullableboolIndicates whether or not the column can store null values.
defaultValueobjectThe default value for the column.
defaultValueSqlstringThe SQL expression to use for the column's default constraint.
computedColumnSqlstringThe SQL expression to use to compute the column value.
fixedLengthbool?Indicates whether or not the column is constrained to fixed-length data.
commentstringA comment to associate with the column.
collationstringA collation to apply to the column.
precisionint?The maximum number of digits that is allowed in this column, or null if not specified or not applicable.
scaleint?The maximum number of decimal places that is allowed in this column, or null if not specified or not applicable.
storedbool?Whether the value of the computed column is stored in the database or not.
Returns
- OperationBuilder<AddColumnOperation>
A builder to allow annotations to be added to the operation.
Type Parameters
TThe CLR type that the column is mapped to.
Remarks
See Database migrations for more information and examples.
AddForeignKey(string, string, string, string, string?, string?, string?, ReferentialAction, ReferentialAction)
Builds an AddForeignKeyOperation to add a new foreign key to a table.
public virtual OperationBuilder<AddForeignKeyOperation> AddForeignKey(string name, string table, string column, string principalTable, string? schema = null, string? principalSchema = null, string? principalColumn = null, ReferentialAction onUpdate = ReferentialAction.NoAction, ReferentialAction onDelete = ReferentialAction.NoAction)
Parameters
namestringThe foreign key constraint name.
tablestringThe table that contains the foreign key.
columnstringThe column that is constrained.
principalTablestringThe table to which the foreign key is constrained.
schemastringThe schema that contains the table, or null if the default schema should be used.
principalSchemastringThe schema that contains principal table, or null if the default schema should be used.
principalColumnstringThe column to which the foreign key column is constrained, or null to constrain to the primary key column.
onUpdateReferentialActionThe action to take on updates.
onDeleteReferentialActionThe action to take on deletes.
Returns
- OperationBuilder<AddForeignKeyOperation>
A builder to allow annotations to be added to the operation.
Remarks
See Database migrations for more information and examples.
AddForeignKey(string, string, string[], string, string?, string?, string[]?, ReferentialAction, ReferentialAction)
Builds an AddForeignKeyOperation to add a new composite (multi-column) foreign key to a table.
public virtual OperationBuilder<AddForeignKeyOperation> AddForeignKey(string name, string table, string[] columns, string principalTable, string? schema = null, string? principalSchema = null, string[]? principalColumns = null, ReferentialAction onUpdate = ReferentialAction.NoAction, ReferentialAction onDelete = ReferentialAction.NoAction)
Parameters
namestringThe foreign key constraint name.
tablestringThe table that contains the foreign key.
columnsstring[]The ordered list of columns that are constrained.
principalTablestringThe table to which the foreign key is constrained.
schemastringThe schema that contains the table, or null if the default schema should be used.
principalSchemastringThe schema that contains principal table, or null if the default schema should be used.
principalColumnsstring[]The columns to which the foreign key columns are constrained, or null to constrain to the primary key columns.
onUpdateReferentialActionThe action to take on updates.
onDeleteReferentialActionThe action to take on deletes.
Returns
- OperationBuilder<AddForeignKeyOperation>
A builder to allow annotations to be added to the operation.
Remarks
See Database migrations for more information and examples.
AddPrimaryKey(string, string, string, string?)
Builds an AddPrimaryKeyOperation to add a new primary key to a table.
public virtual OperationBuilder<AddPrimaryKeyOperation> AddPrimaryKey(string name, string table, string column, string? schema = null)
Parameters
namestringThe primary key constraint name.
tablestringThe table that will contain the primary key.
columnstringThe column that constitutes the primary key.
schemastringThe schema that contains the table, or null to use the default schema.
Returns
- OperationBuilder<AddPrimaryKeyOperation>
A builder to allow annotations to be added to the operation.
Remarks
See Database migrations for more information and examples.
AddPrimaryKey(string, string, string[], string?)
Builds an AddPrimaryKeyOperation to add a new composite (multi-column) primary key to a table.
public virtual OperationBuilder<AddPrimaryKeyOperation> AddPrimaryKey(string name, string table, string[] columns, string? schema = null)
Parameters
namestringThe primary key constraint name.
tablestringThe table that will contain the primary key.
columnsstring[]The ordered list of columns that constitute the primary key.
schemastringThe schema that contains the table, or null to use the default schema.
Returns
- OperationBuilder<AddPrimaryKeyOperation>
A builder to allow annotations to be added to the operation.
Remarks
See Database migrations for more information and examples.
AddUniqueConstraint(string, string, string, string?)
Builds an AddUniqueConstraintOperation to add a new unique constraint to a table.
public virtual OperationBuilder<AddUniqueConstraintOperation> AddUniqueConstraint(string name, string table, string column, string? schema = null)
Parameters
namestringThe constraint name.
tablestringThe table that will contain the constraint.
columnstringThe column that is constrained.
schemastringThe schema that contains the table, or null to use the default schema.
Returns
- OperationBuilder<AddUniqueConstraintOperation>
A builder to allow annotations to be added to the operation.
Remarks
See Database migrations for more information and examples.
AddUniqueConstraint(string, string, string[], string?)
Builds an AddUniqueConstraintOperation to add a new composite (multi-column) unique constraint to a table.
public virtual OperationBuilder<AddUniqueConstraintOperation> AddUniqueConstraint(string name, string table, string[] columns, string? schema = null)
Parameters
namestringThe constraint name.
tablestringThe table that will contain the constraint.
columnsstring[]The ordered list of columns that are constrained.
schemastringThe schema that contains the table, or null to use the default schema.
Returns
- OperationBuilder<AddUniqueConstraintOperation>
A builder to allow annotations to be added to the operation.
Remarks
See Database migrations for more information and examples.
AlterColumn<T>(string, string, string?, bool?, int?, bool, string?, bool, object?, string?, string?, Type?, string?, bool?, int?, bool, bool, object?, string?, string?, bool?, bool?, string?, string?, string?, string?, int?, int?, int?, int?, bool?, bool?)
Builds an AlterColumnOperation to alter an existing column.
public virtual AlterOperationBuilder<AlterColumnOperation> AlterColumn<T>(string name, string table, string? type = null, bool? unicode = null, int? maxLength = null, bool rowVersion = false, string? schema = null, bool nullable = false, object? defaultValue = null, string? defaultValueSql = null, string? computedColumnSql = null, Type? oldClrType = null, string? oldType = null, bool? oldUnicode = null, int? oldMaxLength = null, bool oldRowVersion = false, bool oldNullable = false, object? oldDefaultValue = null, string? oldDefaultValueSql = null, string? oldComputedColumnSql = null, bool? fixedLength = null, bool? oldFixedLength = null, string? comment = null, string? oldComment = null, string? collation = null, string? oldCollation = null, int? precision = null, int? oldPrecision = null, int? scale = null, int? oldScale = null, bool? stored = null, bool? oldStored = null)
Parameters
namestringThe column name.
tablestringThe name of the table that contains the column.
typestringThe store/database type of the column.
unicodebool?Indicates whether or not the column can contain Unicode data, or null if not specified or not applicable.
maxLengthint?The maximum length of data that can be stored in the column, or null if not specified or not applicable.
rowVersionboolIndicates whether or not the column acts as an automatic concurrency token, such as a rowversion/timestamp column in SQL Server.
schemastringThe schema that contains the table, or null if the default schema should be used.
nullableboolIndicates whether or not the column can store null values.
defaultValueobjectThe default value for the column.
defaultValueSqlstringThe SQL expression to use for the column's default constraint.
computedColumnSqlstringThe SQL expression to use to compute the column value.
oldClrTypeTypeThe CLR type that the column was previously mapped to. Can be null, in which case previous value is considered unknown.
oldTypestringThe previous store/database type of the column. Can be null, in which case previous value is considered unknown.
oldUnicodebool?Indicates whether or not the column could previously contain Unicode data, or null if not specified or not applicable.
oldMaxLengthint?The previous maximum length of data that can be stored in the column, or null if not specified or not applicable.
oldRowVersionboolIndicates whether or not the column previously acted as an automatic concurrency token, such as a rowversion/timestamp column in SQL Server. Can be null, in which case previous value is considered unknown.
oldNullableboolIndicates whether or not the column could previously store null values. Can be null, in which case previous value is considered unknown.
oldDefaultValueobjectThe previous default value for the column. Can be null, in which case previous value is considered unknown.
oldDefaultValueSqlstringThe previous SQL expression used for the column's default constraint. Can be null, in which case previous value is considered unknown.
oldComputedColumnSqlstringThe previous SQL expression used to compute the column value. Can be null, in which case previous value is considered unknown.
fixedLengthbool?Indicates whether or not the column is constrained to fixed-length data.
oldFixedLengthbool?Indicates whether or not the column was previously constrained to fixed-length data.
commentstringA comment to associate with the column.
oldCommentstringThe previous comment to associate with the column.
collationstringA collation to apply to the column.
oldCollationstringThe previous collation to apply to the column.
precisionint?The maximum number of digits that is allowed in this column, or null if not specified or not applicable.
oldPrecisionint?The previous maximum number of digits that is allowed in this column, or null if not specified or not applicable.
scaleint?The maximum number of decimal places that is allowed in this column, or null if not specified or not applicable.
oldScaleint?The previous maximum number of decimal places that is allowed in this column, or null if not specified or not applicable.
storedbool?Whether the value of the computed column is stored in the database or not.
oldStoredbool?Whether the value of the previous computed column was stored in the database or not.
Returns
- AlterOperationBuilder<AlterColumnOperation>
A builder to allow annotations to be added to the operation.
Type Parameters
TThe CLR type that the column is mapped to.
Remarks
See Database migrations for more information and examples.
AlterDatabase(string?, string?)
Builds an AlterDatabaseOperation to alter an existing database.
public virtual AlterOperationBuilder<AlterDatabaseOperation> AlterDatabase(string? collation = null, string? oldCollation = null)
Parameters
collationstringA collation to apply to the column.
oldCollationstringThe previous collation to apply to the column.
Returns
- AlterOperationBuilder<AlterDatabaseOperation>
A builder to allow annotations to be added to the operation.
Remarks
See Database migrations for more information and examples.
AlterSequence(string, string?, int, long?, long?, bool, int, long?, long?, bool)
Builds an AlterSequenceOperation to alter an existing sequence.
public virtual AlterOperationBuilder<AlterSequenceOperation> AlterSequence(string name, string? schema = null, int incrementBy = 1, long? minValue = null, long? maxValue = null, bool cyclic = false, int oldIncrementBy = 1, long? oldMinValue = null, long? oldMaxValue = null, bool oldCyclic = false)
Parameters
namestringThe sequence name.
schemastringThe schema that contains the sequence, or null to use the default schema.
incrementByintThe amount to increment by when generating the next value in the sequence, defaulting to 1.
minValuelong?The minimum value of the sequence, or null if not specified.
maxValuelong?The maximum value of the sequence, or null if not specified.
cyclicboolIndicates whether or not the sequence will re-start when the maximum value is reached.
oldIncrementByintThe previous amount to increment by when generating the next value in the sequence, defaulting to 1.
oldMinValuelong?The previous minimum value of the sequence, or null if not specified.
oldMaxValuelong?The previous maximum value of the sequence, or null if not specified.
oldCyclicboolIndicates whether or not the sequence would previously re-start when the maximum value is reached.
Returns
- AlterOperationBuilder<AlterSequenceOperation>
A builder to allow annotations to be added to the operation.
Remarks
See Database migrations for more information and examples.
AlterTable(string, string?, string?, string?)
Builds an AlterTableOperation to alter an existing table.
public virtual AlterOperationBuilder<AlterTableOperation> AlterTable(string name, string? schema = null, string? comment = null, string? oldComment = null)
Parameters
namestringThe table name.
schemastringThe schema that contains the table, or null to use the default schema.
commentstringA comment to associate with the table.
oldCommentstringThe previous comment to associate with the table.
Returns
- AlterOperationBuilder<AlterTableOperation>
A builder to allow annotations to be added to the operation.
Remarks
See Database migrations for more information and examples.
CreateIndex(string, string, string, string?, bool, string?, bool[]?)
Builds a CreateIndexOperation to create a new index.
public virtual OperationBuilder<CreateIndexOperation> CreateIndex(string name, string table, string column, string? schema = null, bool unique = false, string? filter = null, bool[]? descending = null)
Parameters
namestringThe index name.
tablestringThe table that contains the index.
columnstringThe column that is indexed.
schemastringThe schema that contains the table, or null to use the default schema.
uniqueboolIndicates whether or not the index enforces uniqueness.
filterstringThe filter to apply to the index, or null for no filter.
descendingbool[]A set of values indicating whether each corresponding index column has descending sort order. If null, all columns will have ascending order. If an empty array, all columns will have descending order.
Returns
- OperationBuilder<CreateIndexOperation>
A builder to allow annotations to be added to the operation.
Remarks
See Database migrations for more information and examples.
CreateIndex(string, string, string[], string?, bool, string?, bool[]?)
Builds a CreateIndexOperation to create a new composite (multi-column) index.
public virtual OperationBuilder<CreateIndexOperation> CreateIndex(string name, string table, string[] columns, string? schema = null, bool unique = false, string? filter = null, bool[]? descending = null)
Parameters
namestringThe index name.
tablestringThe table that contains the index.
columnsstring[]The ordered list of columns that are indexed.
schemastringThe schema that contains the table, or null to use the default schema.
uniqueboolIndicates whether or not the index enforces uniqueness.
filterstringThe filter to apply to the index, or null for no filter.
descendingbool[]A set of values indicating whether each corresponding index column has descending sort order. If null, all columns will have ascending order.
Returns
- OperationBuilder<CreateIndexOperation>
A builder to allow annotations to be added to the operation.
Remarks
See Database migrations for more information and examples.
CreateSequence(string, string?, long, int, long?, long?, bool)
Builds a CreateSequenceOperation to create a new sequence.
public virtual OperationBuilder<CreateSequenceOperation> CreateSequence(string name, string? schema = null, long startValue = 1, int incrementBy = 1, long? minValue = null, long? maxValue = null, bool cyclic = false)
Parameters
namestringThe sequence name.
schemastringThe schema that contains the sequence, or null to use the default schema.
startValuelongThe value at which the sequence will start, defaulting to 1.
incrementByintThe amount to increment by when generating the next value in the sequence, defaulting to 1.
minValuelong?The minimum value of the sequence, or null if not specified.
maxValuelong?The maximum value of the sequence, or null if not specified.
cyclicboolIndicates whether or not the sequence will re-start when the maximum value is reached.
Returns
- OperationBuilder<CreateSequenceOperation>
A builder to allow annotations to be added to the operation.
Remarks
See Database migrations for more information and examples.
CreateSequence<T>(string, string?, long, int, long?, long?, bool)
Builds a CreateSequenceOperation to create a new sequence.
public virtual OperationBuilder<CreateSequenceOperation> CreateSequence<T>(string name, string? schema = null, long startValue = 1, int incrementBy = 1, long? minValue = null, long? maxValue = null, bool cyclic = false)
Parameters
namestringThe sequence name.
schemastringThe schema that contains the sequence, or null to use the default schema.
startValuelongThe value at which the sequence will start, defaulting to 1.
incrementByintThe amount to increment by when generating the next value in the sequence, defaulting to 1.
minValuelong?The minimum value of the sequence, or null if not specified.
maxValuelong?The maximum value of the sequence, or null if not specified.
cyclicboolIndicates whether or not the sequence will re-start when the maximum value is reached.
Returns
- OperationBuilder<CreateSequenceOperation>
A builder to allow annotations to be added to the operation.
Type Parameters
TThe CLR type of the values generated by the sequence.
Remarks
See Database migrations for more information and examples.
CreateTable<TColumns>(string, Func<ColumnsBuilder, TColumns>, string?, Action<CreateTableBuilder<TColumns>>?, string?)
Builds a CreateTableOperation to create a new table.
public virtual CreateTableBuilder<TColumns> CreateTable<TColumns>(string name, Func<ColumnsBuilder, TColumns> columns, string? schema = null, Action<CreateTableBuilder<TColumns>>? constraints = null, string? comment = null)
Parameters
namestringThe name of the table.
columnsFunc<ColumnsBuilder, TColumns>A delegate using a ColumnsBuilder to create an anonymous type configuring the columns of the table.
schemastringThe schema that contains the table, or null to use the default schema.
constraintsAction<CreateTableBuilder<TColumns>>A delegate allowing constraints to be applied over the columns configured by the 'columns' delegate above.
commentstringA comment to be applied to the table.
Returns
- CreateTableBuilder<TColumns>
A CreateTableBuilder<TColumns> to allow further configuration to be chained.
Type Parameters
TColumnsType of a typically anonymous type for building columns.
Remarks
See Database migrations for more information and examples.
DeleteData(string, string, object?, string?)
Builds a DeleteDataOperation to delete a single row of seed data.
public virtual OperationBuilder<DeleteDataOperation> DeleteData(string table, string keyColumn, object? keyValue, string? schema = null)
Parameters
tablestringThe table from which the data will be deleted.
keyColumnstringThe name of the key column used to select the row to delete.
keyValueobjectThe key value of the row to delete.
schemastringThe schema that contains the table, or null to use the default schema.
Returns
- OperationBuilder<DeleteDataOperation>
A builder to allow annotations to be added to the operation.
Remarks
See Database migrations for more information and examples.
DeleteData(string, string, object[], string?)
Builds a DeleteDataOperation to delete multiple rows of seed data.
public virtual OperationBuilder<DeleteDataOperation> DeleteData(string table, string keyColumn, object[] keyValues, string? schema = null)
Parameters
tablestringThe table from which the data will be deleted.
keyColumnstringThe name of the key column used to select the row to delete.
keyValuesobject[]The key values of the rows to delete, one value per row.
schemastringThe schema that contains the table, or null to use the default schema.
Returns
- OperationBuilder<DeleteDataOperation>
A builder to allow annotations to be added to the operation.
Remarks
See Database migrations for more information and examples.
DeleteData(string, string, string, object?, string?)
Builds a DeleteDataOperation to delete a single row of seed data.
public virtual OperationBuilder<DeleteDataOperation> DeleteData(string table, string keyColumn, string keyColumnType, object? keyValue, string? schema = null)
Parameters
tablestringThe table from which the data will be deleted.
keyColumnstringThe name of the key column used to select the row to delete.
keyColumnTypestringThe store type for the column that will be used to identify the rows that should be deleted.
keyValueobjectThe key value of the row to delete.
schemastringThe schema that contains the table, or null to use the default schema.
Returns
- OperationBuilder<DeleteDataOperation>
A builder to allow annotations to be added to the operation.
Remarks
See Database migrations for more information and examples.
DeleteData(string, string, string, object[], string?)
Builds a DeleteDataOperation to delete multiple rows of seed data.
public virtual OperationBuilder<DeleteDataOperation> DeleteData(string table, string keyColumn, string keyColumnType, object[] keyValues, string? schema = null)
Parameters
tablestringThe table from which the data will be deleted.
keyColumnstringThe name of the key column used to select the row to delete.
keyColumnTypestringThe store type for the column that will be used to identify the rows that should be deleted.
keyValuesobject[]The key values of the rows to delete, one value per row.
schemastringThe schema that contains the table, or null to use the default schema.
Returns
- OperationBuilder<DeleteDataOperation>
A builder to allow annotations to be added to the operation.
Remarks
See Database migrations for more information and examples.
DeleteData(string, string[], object?[,], string?)
Builds a DeleteDataOperation to delete multiple rows of seed data from a table with a composite (multi-column) key.
public virtual OperationBuilder<DeleteDataOperation> DeleteData(string table, string[] keyColumns, object?[,] keyValues, string? schema = null)
Parameters
tablestringThe table from which the data will be deleted.
keyColumnsstring[]The names of the key columns used to select the rows to delete.
keyValuesobject[,]The key values of the rows to delete, where each element of the outer array represents a row, and each inner array contains values for each of the key columns in 'keyColumns'.
schemastringThe schema that contains the table, or null to use the default schema.
Returns
- OperationBuilder<DeleteDataOperation>
A builder to allow annotations to be added to the operation.
Remarks
See Database migrations for more information and examples.
DeleteData(string, string[], object?[], string?)
Builds a DeleteDataOperation to delete a single row of seed data from a table with a composite (multi-column) key.
public virtual OperationBuilder<DeleteDataOperation> DeleteData(string table, string[] keyColumns, object?[] keyValues, string? schema = null)
Parameters
tablestringThe table from which the data will be deleted.
keyColumnsstring[]The names of the key columns used to select the row to delete.
keyValuesobject[]The key values of the row to delete, one value for each column in 'keyColumns'.
schemastringThe schema that contains the table, or null to use the default schema.
Returns
- OperationBuilder<DeleteDataOperation>
A builder to allow annotations to be added to the operation.
Remarks
See Database migrations for more information and examples.
DeleteData(string, string[], string[], object?[,], string?)
Builds a DeleteDataOperation to delete multiple rows of seed data from a table with a composite (multi-column) key.
public virtual OperationBuilder<DeleteDataOperation> DeleteData(string table, string[] keyColumns, string[] keyColumnTypes, object?[,] keyValues, string? schema = null)
Parameters
tablestringThe table from which the data will be deleted.
keyColumnsstring[]The names of the key columns used to select the rows to delete.
keyColumnTypesstring[]The store types for the columns that will be used to identify the rows that should be deleted.
keyValuesobject[,]The key values of the rows to delete, where each element of the outer array represents a row, and each inner array contains values for each of the key columns in 'keyColumns'.
schemastringThe schema that contains the table, or null to use the default schema.
Returns
- OperationBuilder<DeleteDataOperation>
A builder to allow annotations to be added to the operation.
Remarks
See Database migrations for more information and examples.
DeleteData(string, string[], string[], object?[], string?)
Builds a DeleteDataOperation to delete a single row of seed data from a table with a composite (multi-column) key.
public virtual OperationBuilder<DeleteDataOperation> DeleteData(string table, string[] keyColumns, string[] keyColumnTypes, object?[] keyValues, string? schema = null)
Parameters
tablestringThe table from which the data will be deleted.
keyColumnsstring[]The names of the key columns used to select the row to delete.
keyColumnTypesstring[]The store types for the columns that will be used to identify the rows that should be deleted.
keyValuesobject[]The key values of the row to delete, one value for each column in 'keyColumns'.
schemastringThe schema that contains the table, or null to use the default schema.
Returns
- OperationBuilder<DeleteDataOperation>
A builder to allow annotations to be added to the operation.
Remarks
See Database migrations for more information and examples.
DropCheckConstraint(string, string, string?)
Builds a DropCheckConstraintOperation to drop an existing check constraint.
public virtual OperationBuilder<DropCheckConstraintOperation> DropCheckConstraint(string name, string table, string? schema = null)
Parameters
namestringThe name of the check constraint to drop.
tablestringThe name of the table for the check constraint to drop.
schemastringThe schema that contains the check constraint, or null to use the default schema.
Returns
- OperationBuilder<DropCheckConstraintOperation>
A builder to allow annotations to be added to the operation.
Remarks
See Database migrations for more information and examples.
DropColumn(string, string, string?)
Builds a DropColumnOperation to drop an existing column.
public virtual OperationBuilder<DropColumnOperation> DropColumn(string name, string table, string? schema = null)
Parameters
namestringThe name of the column to drop.
tablestringThe table that contains the column.
schemastringThe schema that contains the table, or null to use the default schema.
Returns
- OperationBuilder<DropColumnOperation>
A builder to allow annotations to be added to the operation.
Remarks
See Database migrations for more information and examples.
DropForeignKey(string, string, string?)
Builds a DropForeignKeyOperation to drop an existing foreign key constraint.
public virtual OperationBuilder<DropForeignKeyOperation> DropForeignKey(string name, string table, string? schema = null)
Parameters
namestringThe name of the foreign key constraint to drop.
tablestringThe table that contains the foreign key.
schemastringThe schema that contains the table, or null to use the default schema.
Returns
- OperationBuilder<DropForeignKeyOperation>
A builder to allow annotations to be added to the operation.
Remarks
See Database migrations for more information and examples.
DropIndex(string, string?, string?)
Builds a DropIndexOperation to drop an existing index.
public virtual OperationBuilder<DropIndexOperation> DropIndex(string name, string? table = null, string? schema = null)
Parameters
namestringThe name of the index to drop.
tablestringThe table that contains the index.
schemastringThe schema that contains the table, or null to use the default schema.
Returns
- OperationBuilder<DropIndexOperation>
A builder to allow annotations to be added to the operation.
Remarks
See Database migrations for more information and examples.
DropPrimaryKey(string, string, string?)
Builds a DropPrimaryKeyOperation to drop an existing primary key.
public virtual OperationBuilder<DropPrimaryKeyOperation> DropPrimaryKey(string name, string table, string? schema = null)
Parameters
namestringThe name of the primary key constraint to drop.
tablestringThe table that contains the key.
schemastringThe schema that contains the table, or null to use the default schema.
Returns
- OperationBuilder<DropPrimaryKeyOperation>
A builder to allow annotations to be added to the operation.
Remarks
See Database migrations for more information and examples.
DropSchema(string)
Builds a DropSchemaOperation to drop an existing schema.
public virtual OperationBuilder<DropSchemaOperation> DropSchema(string name)
Parameters
namestringThe name of the schema to drop.
Returns
- OperationBuilder<DropSchemaOperation>
A builder to allow annotations to be added to the operation.
Remarks
See Database migrations for more information and examples.
DropSequence(string, string?)
Builds a DropSequenceOperation to drop an existing sequence.
public virtual OperationBuilder<DropSequenceOperation> DropSequence(string name, string? schema = null)
Parameters
namestringThe name of the sequence to drop.
schemastringThe schema that contains the sequence, or null to use the default schema.
Returns
- OperationBuilder<DropSequenceOperation>
A builder to allow annotations to be added to the operation.
Remarks
See Database migrations for more information and examples.
DropTable(string, string?)
Builds a DropTableOperation to drop an existing table.
public virtual OperationBuilder<DropTableOperation> DropTable(string name, string? schema = null)
Parameters
namestringThe name of the table to drop.
schemastringThe schema that contains the table, or null to use the default schema.
Returns
- OperationBuilder<DropTableOperation>
A builder to allow annotations to be added to the operation.
Remarks
See Database migrations for more information and examples.
DropUniqueConstraint(string, string, string?)
Builds a DropUniqueConstraintOperation to drop an existing unique constraint.
public virtual OperationBuilder<DropUniqueConstraintOperation> DropUniqueConstraint(string name, string table, string? schema = null)
Parameters
namestringThe name of the constraint to drop.
tablestringThe table that contains the constraint.
schemastringThe schema that contains the table, or null to use the default schema.
Returns
- OperationBuilder<DropUniqueConstraintOperation>
A builder to allow annotations to be added to the operation.
Remarks
See Database migrations for more information and examples.
EnsureSchema(string)
Builds an EnsureSchemaOperation to ensure that a schema exists.
public virtual OperationBuilder<EnsureSchemaOperation> EnsureSchema(string name)
Parameters
namestringThe name of the schema.
Returns
- OperationBuilder<EnsureSchemaOperation>
A builder to allow annotations to be added to the operation.
Remarks
See Database migrations for more information and examples.
InsertData(string, string, object?, string?)
Builds an InsertDataOperation to insert a single seed data value for a single column.
public virtual OperationBuilder<InsertDataOperation> InsertData(string table, string column, object? value, string? schema = null)
Parameters
tablestringThe table into which the data will be inserted.
columnstringThe name of the column into which the data will be inserted.
valueobjectThe value to insert.
schemastringThe schema that contains the table, or null to use the default schema.
Returns
- OperationBuilder<InsertDataOperation>
A builder to allow annotations to be added to the operation.
Remarks
See Database migrations for more information and examples.
InsertData(string, string, object[], string?)
Builds an InsertDataOperation to insert multiple rows of seed data values for a single column.
public virtual OperationBuilder<InsertDataOperation> InsertData(string table, string column, object[] values, string? schema = null)
Parameters
tablestringThe table into which the data will be inserted.
columnstringThe name of the column into which the data will be inserted.
valuesobject[]The values to insert, one value for each row.
schemastringThe schema that contains the table, or null to use the default schema.
Returns
- OperationBuilder<InsertDataOperation>
A builder to allow annotations to be added to the operation.
Remarks
See Database migrations for more information and examples.
InsertData(string, string, string, object?, string?)
Builds an InsertDataOperation to insert a single seed data value for a single column.
public virtual OperationBuilder<InsertDataOperation> InsertData(string table, string column, string columnType, object? value, string? schema = null)
Parameters
tablestringThe table into which the data will be inserted.
columnstringThe name of the column into which the data will be inserted.
columnTypestringThe store type for the column into which data will be inserted.
valueobjectThe value to insert.
schemastringThe schema that contains the table, or null to use the default schema.
Returns
- OperationBuilder<InsertDataOperation>
A builder to allow annotations to be added to the operation.
Remarks
See Database migrations for more information and examples.
InsertData(string, string, string, object[], string?)
Builds an InsertDataOperation to insert multiple rows of seed data values for a single column.
public virtual OperationBuilder<InsertDataOperation> InsertData(string table, string column, string columnType, object[] values, string? schema = null)
Parameters
tablestringThe table into which the data will be inserted.
columnstringThe name of the column into which the data will be inserted.
columnTypestringThe store type for the column into which data will be inserted.
valuesobject[]The values to insert, one value for each row.
schemastringThe schema that contains the table, or null to use the default schema.
Returns
- OperationBuilder<InsertDataOperation>
A builder to allow annotations to be added to the operation.
Remarks
See Database migrations for more information and examples.
InsertData(string, string[], object?[,], string?)
Builds an InsertDataOperation to insert multiple rows of seed data values for multiple columns.
public virtual OperationBuilder<InsertDataOperation> InsertData(string table, string[] columns, object?[,] values, string? schema = null)
Parameters
tablestringThe table into which the data will be inserted.
columnsstring[]The names of the columns into which the data will be inserted.
valuesobject[,]The values to insert where each element of the outer array represents a row, and each inner array contains values for each of the columns in 'columns'.
schemastringThe schema that contains the table, or null to use the default schema.
Returns
- OperationBuilder<InsertDataOperation>
A builder to allow annotations to be added to the operation.
Remarks
See Database migrations for more information and examples.
InsertData(string, string[], object?[], string?)
Builds an InsertDataOperation to insert a single row of seed data values.
public virtual OperationBuilder<InsertDataOperation> InsertData(string table, string[] columns, object?[] values, string? schema = null)
Parameters
tablestringThe table into which the data will be inserted.
columnsstring[]The names of the columns into which the data will be inserted.
valuesobject[]The values to insert, one value for each column in 'columns'.
schemastringThe schema that contains the table, or null to use the default schema.
Returns
- OperationBuilder<InsertDataOperation>
A builder to allow annotations to be added to the operation.
Remarks
See Database migrations for more information and examples.
InsertData(string, string[], string[], object?[,], string?)
Builds an InsertDataOperation to insert multiple rows of seed data values for multiple columns.
public virtual OperationBuilder<InsertDataOperation> InsertData(string table, string[] columns, string[] columnTypes, object?[,] values, string? schema = null)
Parameters
tablestringThe table into which the data will be inserted.
columnsstring[]The names of the columns into which the data will be inserted.
columnTypesstring[]A list of store types for the columns into which data will be inserted.
valuesobject[,]The values to insert where each element of the outer array represents a row, and each inner array contains values for each of the columns in 'columns'.
schemastringThe schema that contains the table, or null to use the default schema.
Returns
- OperationBuilder<InsertDataOperation>
A builder to allow annotations to be added to the operation.
Remarks
See Database migrations for more information and examples.
InsertData(string, string[], string[], object?[], string?)
Builds an InsertDataOperation to insert a single row of seed data values.
public virtual OperationBuilder<InsertDataOperation> InsertData(string table, string[] columns, string[] columnTypes, object?[] values, string? schema = null)
Parameters
tablestringThe table into which the data will be inserted.
columnsstring[]The names of the columns into which the data will be inserted.
columnTypesstring[]A list of store types for the columns into which data will be inserted.
valuesobject[]The values to insert, one value for each column in 'columns'.
schemastringThe schema that contains the table, or null to use the default schema.
Returns
- OperationBuilder<InsertDataOperation>
A builder to allow annotations to be added to the operation.
Remarks
See Database migrations for more information and examples.
RenameColumn(string, string, string, string?)
Builds a RenameColumnOperation to rename an existing column.
public virtual OperationBuilder<RenameColumnOperation> RenameColumn(string name, string table, string newName, string? schema = null)
Parameters
namestringThe name of the column to be renamed.
tablestringThe table that contains the column.
newNamestringThe new name for the column.
schemastringThe schema that contains the table, or null to use the default schema.
Returns
- OperationBuilder<RenameColumnOperation>
A builder to allow annotations to be added to the operation.
Remarks
See Database migrations for more information and examples.
RenameIndex(string, string, string?, string?)
Builds a RenameIndexOperation to rename an existing index.
public virtual OperationBuilder<RenameIndexOperation> RenameIndex(string name, string newName, string? table = null, string? schema = null)
Parameters
namestringThe name of the index to be renamed.
newNamestringThe new name for the column.
tablestringThe table that contains the index.
schemastringThe schema that contains the table, or null to use the default schema.
Returns
- OperationBuilder<RenameIndexOperation>
A builder to allow annotations to be added to the operation.
Remarks
See Database migrations for more information and examples.
RenameSequence(string, string?, string?, string?)
Builds a RenameSequenceOperation to rename an existing sequence.
public virtual OperationBuilder<RenameSequenceOperation> RenameSequence(string name, string? schema = null, string? newName = null, string? newSchema = null)
Parameters
namestringThe name of the sequence to be renamed.
schemastringThe schema that contains the sequence, or null to use the default schema.
newNamestringThe new sequence name or null if only the schema has changed.
newSchemastringThe new schema name or null if only the name has changed.
Returns
- OperationBuilder<RenameSequenceOperation>
A builder to allow annotations to be added to the operation.
Remarks
See Database migrations for more information and examples.
RenameTable(string, string?, string?, string?)
Builds a RenameTableOperation to rename an existing table.
public virtual OperationBuilder<RenameTableOperation> RenameTable(string name, string? schema = null, string? newName = null, string? newSchema = null)
Parameters
namestringThe name of the table to be renamed.
schemastringThe schema that contains the table, or null to use the default schema.
newNamestringThe new table name or null if only the schema has changed.
newSchemastringThe new schema name, or null to use the default schema.
Returns
- OperationBuilder<RenameTableOperation>
A builder to allow annotations to be added to the operation.
Remarks
See Database migrations for more information and examples.
RestartSequence(string, long, string?)
Builds a RestartSequenceOperation to re-start an existing sequence.
public virtual OperationBuilder<RestartSequenceOperation> RestartSequence(string name, long startValue = 1, string? schema = null)
Parameters
namestringThe name of the sequence.
startValuelongThe value at which the sequence will start, defaulting to 1.
schemastringThe schema that contains the sequence, or null to use the default schema.
Returns
- OperationBuilder<RestartSequenceOperation>
A builder to allow annotations to be added to the operation.
Remarks
See Database migrations for more information and examples.
Sql(string, bool)
Builds an SqlOperation to execute raw SQL.
public virtual OperationBuilder<SqlOperation> Sql(string sql, bool suppressTransaction = false)
Parameters
sqlstringThe SQL string to be executed to perform the operation.
suppressTransactionboolIndicates whether or not transactions will be suppressed while executing the SQL.
Returns
- OperationBuilder<SqlOperation>
A builder to allow annotations to be added to the operation.
Remarks
See Database migrations for more information and examples.
UpdateData(string, string, object?, string, object?, string?)
Builds an UpdateDataOperation to update a single row of seed data.
public virtual OperationBuilder<UpdateDataOperation> UpdateData(string table, string keyColumn, object? keyValue, string column, object? value, string? schema = null)
Parameters
tablestringThe table containing the data to be updated.
keyColumnstringThe name of the key column used to select the row to update.
keyValueobjectThe key value of the row to update.
columnstringThe column to update.
valueobjectThe new value for the column in the selected row.
schemastringThe schema that contains the table, or null to use the default schema.
Returns
- OperationBuilder<UpdateDataOperation>
A builder to allow annotations to be added to the operation.
Remarks
See Database migrations for more information and examples.
UpdateData(string, string, object?, string[], object?[], string?)
Builds an UpdateDataOperation to update a single row of seed data.
public virtual OperationBuilder<UpdateDataOperation> UpdateData(string table, string keyColumn, object? keyValue, string[] columns, object?[] values, string? schema = null)
Parameters
tablestringThe table containing the data to be updated.
keyColumnstringThe name of the key column used to select the row to update.
keyValueobjectThe key value of the row to update.
columnsstring[]The columns to update.
valuesobject[]The new values, one for each column in 'columns', for the selected row.
schemastringThe schema that contains the table, or null to use the default schema.
Returns
- OperationBuilder<UpdateDataOperation>
A builder to allow annotations to be added to the operation.
Remarks
See Database migrations for more information and examples.
UpdateData(string, string, object[], string, object[], string?)
Builds an UpdateDataOperation to update multiple rows of seed data.
public virtual OperationBuilder<UpdateDataOperation> UpdateData(string table, string keyColumn, object[] keyValues, string column, object[] values, string? schema = null)
Parameters
tablestringThe table containing the data to be updated.
keyColumnstringThe name of the key column used to select the row to update.
keyValuesobject[]The key values of the rows to update, one value per row.
columnstringThe column to update.
valuesobject[]The new values for the column, one for each row specified in 'keyValues'.
schemastringThe schema that contains the table, or null to use the default schema.
Returns
- OperationBuilder<UpdateDataOperation>
A builder to allow annotations to be added to the operation.
Remarks
See Database migrations for more information and examples.
UpdateData(string, string, object[], string[], object?[,], string?)
Builds an UpdateDataOperation to update multiple rows of seed data.
public virtual OperationBuilder<UpdateDataOperation> UpdateData(string table, string keyColumn, object[] keyValues, string[] columns, object?[,] values, string? schema = null)
Parameters
tablestringThe table containing the data to be updated.
keyColumnstringThe name of the key column used to select the row to update.
keyValuesobject[]The key values of the rows to update, one value per row.
columnsstring[]The columns to update.
valuesobject[,]The values for each update, where each element of the outer array represents a row specified in 'keyValues', and each inner array contains values for each of the columns in 'columns'.
schemastringThe schema that contains the table, or null to use the default schema.
Returns
- OperationBuilder<UpdateDataOperation>
A builder to allow annotations to be added to the operation.
Remarks
See Database migrations for more information and examples.
UpdateData(string, string[], object[,], string, object[], string?)
Builds an UpdateDataOperation to update multiple rows of seed data for a table with a composite (multi-column) key.
public virtual OperationBuilder<UpdateDataOperation> UpdateData(string table, string[] keyColumns, object[,] keyValues, string column, object[] values, string? schema = null)
Parameters
tablestringThe table containing the data to be updated.
keyColumnsstring[]The names of the key columns used to select the rows to update.
keyValuesobject[,]The key values of the rows to update, where each element of the outer array represents a row, and each inner array contains values for each of the key columns in 'keyColumns'.
columnstringThe column to update.
valuesobject[]The new values for the column, one for each row specified in 'keyValues'.
schemastringThe schema that contains the table, or null to use the default schema.
Returns
- OperationBuilder<UpdateDataOperation>
A builder to allow annotations to be added to the operation.
Remarks
See Database migrations for more information and examples.
UpdateData(string, string[], object?[,], string[], object?[,], string?)
Builds an UpdateDataOperation to update multiple rows of seed data for a table with a composite (multi-column) key.
public virtual OperationBuilder<UpdateDataOperation> UpdateData(string table, string[] keyColumns, object?[,] keyValues, string[] columns, object?[,] values, string? schema = null)
Parameters
tablestringThe table containing the data to be updated.
keyColumnsstring[]The names of the key columns used to select the rows to update.
keyValuesobject[,]The key values of the rows to update, where each element of the outer array represents a row, and each inner array contains values for each of the key columns in 'keyColumns'.
columnsstring[]The columns to update.
valuesobject[,]The values for each update, where each element of the outer array represents a row specified in 'keyValues', and each inner array contains values for each of the columns in 'columns'.
schemastringThe schema that contains the table, or null to use the default schema.
Returns
- OperationBuilder<UpdateDataOperation>
A builder to allow annotations to be added to the operation.
Remarks
See Database migrations for more information and examples.
UpdateData(string, string[], object[], string, object?, string?)
Builds an UpdateDataOperation to update a single row of seed data for a table with a composite (multi-column) key.
public virtual OperationBuilder<UpdateDataOperation> UpdateData(string table, string[] keyColumns, object[] keyValues, string column, object? value, string? schema = null)
Parameters
tablestringThe table containing the data to be updated.
keyColumnsstring[]The names of the key columns used to select the row to update.
keyValuesobject[]The key values of the row to update, one value for each column in 'keyColumns'.
columnstringThe column to update.
valueobjectThe new value for the column in the selected row.
schemastringThe schema that contains the table, or null to use the default schema.
Returns
- OperationBuilder<UpdateDataOperation>
A builder to allow annotations to be added to the operation.
Remarks
See Database migrations for more information and examples.
UpdateData(string, string[], object?[], string[], object?[], string?)
Builds an UpdateDataOperation to update a single row of seed data for a table with a composite (multi-column) key.
public virtual OperationBuilder<UpdateDataOperation> UpdateData(string table, string[] keyColumns, object?[] keyValues, string[] columns, object?[] values, string? schema = null)
Parameters
tablestringThe table containing the data to be updated.
keyColumnsstring[]The names of the key columns used to select the row to update.
keyValuesobject[]The key values of the row to update, one value for each column in 'keyColumns'.
columnsstring[]The columns to update.
valuesobject[]The new values, one for each column in 'columns', for the selected row.
schemastringThe schema that contains the table, or null to use the default schema.
Returns
- OperationBuilder<UpdateDataOperation>
A builder to allow annotations to be added to the operation.
Remarks
See Database migrations for more information and examples.
UpdateData(string, string[], string[], object?[,], string[], string[], object?[,], string?)
Builds an UpdateDataOperation to update multiple rows of seed data for a table with a composite (multi-column) key.
public virtual OperationBuilder<UpdateDataOperation> UpdateData(string table, string[] keyColumns, string[] keyColumnTypes, object?[,] keyValues, string[] columns, string[] columnTypes, object?[,] values, string? schema = null)
Parameters
tablestringThe table containing the data to be updated.
keyColumnsstring[]The names of the key columns used to select the rows to update.
keyColumnTypesstring[]A list of store types for the columns that will be used to identify the rows that should be updated.
keyValuesobject[,]The key values of the rows to update, where each element of the outer array represents a row, and each inner array contains values for each of the key columns in 'keyColumns'.
columnsstring[]The columns to update.
columnTypesstring[]A list of store types for the columns in which data will be updated.
valuesobject[,]The values for each update, where each element of the outer array represents a row specified in 'keyValues', and each inner array contains values for each of the columns in 'columns'.
schemastringThe schema that contains the table, or null to use the default schema.
Returns
- OperationBuilder<UpdateDataOperation>
A builder to allow annotations to be added to the operation.
Remarks
See Database migrations for more information and examples.
UpdateData(string, string[], string[], object[], string[], string[], object[], string?)
Builds an UpdateDataOperation to update a single row of seed data for a table with a composite (multi-column) key.
public virtual OperationBuilder<UpdateDataOperation> UpdateData(string table, string[] keyColumns, string[] keyColumnTypes, object[] keyValues, string[] columns, string[] columnTypes, object[] values, string? schema = null)
Parameters
tablestringThe table containing the data to be updated.
keyColumnsstring[]The names of the key columns used to select the row to update.
keyColumnTypesstring[]A list of store types for the columns that will be used to identify the rows that should be updated.
keyValuesobject[]The key values of the row to update, one value for each column in 'keyColumns'.
columnsstring[]The columns to update.
columnTypesstring[]A list of store types for the columns in which data will be updated.
valuesobject[]The new values, one for each column in 'columns', for the selected row.
schemastringThe schema that contains the table, or null to use the default schema.
Returns
- OperationBuilder<UpdateDataOperation>
A builder to allow annotations to be added to the operation.
Remarks
See Database migrations for more information and examples.