Table of Contents

Class CreateTableBuilder<TColumns>

Namespace
Microsoft.EntityFrameworkCore.Migrations.Operations.Builders
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 CreateTableOperation

The 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

name string

The annotation name.

value object

The annotation value.

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

name string

The constraint name.

sql string

The sql expression used in the CHECK constraint.

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 string

The foreign key constraint name.

column Expression<Func<TColumns, object>>

The column used for the foreign key.

principalTable string

The table to which the foreign key is constrained.

principalColumn string

The column to which the foreign key column is constrained.

principalSchema string

The schema that contains the table to which the foreign key is constrained.

onUpdate ReferentialAction

The ReferentialAction to use for updates.

onDelete ReferentialAction

The 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 string

The foreign key constraint name.

columns Expression<Func<TColumns, object>>

The columns used for the foreign key.

principalTable string

The table to which the foreign key is constrained.

principalColumns string[]

The columns to which the foreign key column is constrained.

principalSchema string

The schema that contains the table to which the foreign key is constrained.

onUpdate ReferentialAction

The ReferentialAction to use for updates.

onDelete ReferentialAction

The 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 string

The 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 string

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