Class CreateTableBuilder<TColumns>
- Assembly
- Microsoft.EntityFrameworkCore.Relational.dll
A builder for CreateTableOperation operations.
public class CreateTableBuilder<TColumns> : OperationBuilder<CreateTableOperation>, IInfrastructure<CreateTableOperation>
Type Parameters
TColumns
Type of a typically anonymous type for building columns.
- Inheritance
-
CreateTableBuilder<TColumns>
- Implements
-
IInfrastructure<CreateTableOperation>
- Inherited Members
Constructors
CreateTableBuilder(CreateTableOperation, IReadOnlyDictionary<PropertyInfo, AddColumnOperation>)
Constructs a new builder for the given CreateTableOperation and with the given map of AddColumnOperation operations for columns.
public CreateTableBuilder(CreateTableOperation operation, IReadOnlyDictionary<PropertyInfo, AddColumnOperation> columnMap)
Parameters
operation
CreateTableOperationThe CreateTableOperation.
columnMap
IReadOnlyDictionary<PropertyInfo, AddColumnOperation>The map of CLR properties to AddColumnOperations.
Methods
Annotation(string, object)
Annotates the operation with the given name/value pair.
public virtual CreateTableBuilder<TColumns> Annotation(string name, object value)
Parameters
Returns
- CreateTableBuilder<TColumns>
The same builder so that multiple calls can be chained.
CheckConstraint(string, string)
Configures a check constraint on the table.
public virtual OperationBuilder<AddCheckConstraintOperation> CheckConstraint(string name, string sql)
Parameters
Returns
- OperationBuilder<AddCheckConstraintOperation>
The same builder so that multiple calls can be chained.
ForeignKey(string, Expression<Func<TColumns, object>>, string, string, string, ReferentialAction, ReferentialAction)
Configures a single-column foreign key on the table.
public virtual OperationBuilder<AddForeignKeyOperation> ForeignKey(string name, Expression<Func<TColumns, object>> column, string principalTable, string principalColumn, string principalSchema = null, ReferentialAction onUpdate = ReferentialAction.NoAction, ReferentialAction onDelete = ReferentialAction.NoAction)
Parameters
name
stringThe foreign key constraint name.
column
Expression<Func<TColumns, object>>The column used for the foreign key.
principalTable
stringThe table to which the foreign key is constrained.
principalColumn
stringThe column to which the foreign key column is constrained.
principalSchema
stringThe schema that contains the table to which the foreign key is constrained.
onUpdate
ReferentialActionThe ReferentialAction to use for updates.
onDelete
ReferentialActionThe ReferentialAction to use for deletes.
Returns
- OperationBuilder<AddForeignKeyOperation>
The same builder so that multiple calls can be chained.
ForeignKey(string, Expression<Func<TColumns, object>>, string, string[], string, ReferentialAction, ReferentialAction)
Configures a multiple-column (composite) foreign key on the table.
public virtual OperationBuilder<AddForeignKeyOperation> ForeignKey(string name, Expression<Func<TColumns, object>> columns, string principalTable, string[] principalColumns, string principalSchema = null, ReferentialAction onUpdate = ReferentialAction.NoAction, ReferentialAction onDelete = ReferentialAction.NoAction)
Parameters
name
stringThe foreign key constraint name.
columns
Expression<Func<TColumns, object>>The columns used for the foreign key.
principalTable
stringThe table to which the foreign key is constrained.
principalColumns
string[]The columns to which the foreign key column is constrained.
principalSchema
stringThe schema that contains the table to which the foreign key is constrained.
onUpdate
ReferentialActionThe ReferentialAction to use for updates.
onDelete
ReferentialActionThe ReferentialAction to use for deletes.
Returns
- OperationBuilder<AddForeignKeyOperation>
The same builder so that multiple calls can be chained.
PrimaryKey(string, Expression<Func<TColumns, object>>)
Configures a primary key on the table.
public virtual OperationBuilder<AddPrimaryKeyOperation> PrimaryKey(string name, Expression<Func<TColumns, object>> columns)
Parameters
name
stringThe primary key constraint name.
columns
Expression<Func<TColumns, object>>The columns that make up the primary key.
Returns
- OperationBuilder<AddPrimaryKeyOperation>
The same builder so that multiple calls can be chained.
UniqueConstraint(string, Expression<Func<TColumns, object>>)
Configures a unique constraint on the table.
public virtual OperationBuilder<AddUniqueConstraintOperation> UniqueConstraint(string name, Expression<Func<TColumns, object>> columns)
Parameters
name
stringThe constraint name.
columns
Expression<Func<TColumns, object>>The columns that make up the constraint.
Returns
- OperationBuilder<AddUniqueConstraintOperation>
The same builder so that multiple calls can be chained.