Class CreateBuilder
Provides a fluent interface for building and executing create expressions as part of database migrations. Used to define new database schema elements such as tables or columns during a migration.
Inheritance
Namespace: Umbraco.Cms.Infrastructure.Migrations.Expressions.Create
Assembly: Umbraco.Infrastructure.dll
Syntax
public class CreateBuilder : ICreateBuilder, IFluentBuilder
Constructors
View SourceCreateBuilder(IMigrationContext)
Initializes a new instance of the CreateBuilder class.
Declaration
public CreateBuilder(IMigrationContext context)
Parameters
| Type | Name | Description |
|---|---|---|
| IMigrationContext | context | The migration context used for the creation operation. |
Methods
View SourceColumn(string)
Begins building an expression to create a new column in a database table.
Declaration
public ICreateColumnOnTableBuilder Column(string columnName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | columnName | The name of the column to create. |
Returns
| Type | Description |
|---|---|
| ICreateColumnOnTableBuilder | An Umbraco.Cms.Infrastructure.Migrations.Expressions.Create.ICreateColumnOnTableBuilder to continue building the column definition on the table. |
Constraint(string)
Begins building a CREATE CONSTRAINT expression for the specified constraint name.
Declaration
public ICreateConstraintOnTableBuilder Constraint(string constraintName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | constraintName | The name of the constraint to create. |
Returns
| Type | Description |
|---|---|
| ICreateConstraintOnTableBuilder | An Umbraco.Cms.Infrastructure.Migrations.Expressions.Create.ICreateConstraintOnTableBuilder that can be used to further define the constraint. |
ForeignKey()
Begins building a 'Create Foreign Key' expression for a database migration.
Declaration
public ICreateForeignKeyFromTableBuilder ForeignKey()
Returns
| Type | Description |
|---|---|
| ICreateForeignKeyFromTableBuilder | An Umbraco.Cms.Infrastructure.Migrations.Expressions.Create.ICreateForeignKeyFromTableBuilder that allows further configuration of the foreign key. |
ForeignKey(string)
Begins building a 'Create Foreign Key' expression for a database migration with the specified foreign key name.
Declaration
public ICreateForeignKeyFromTableBuilder ForeignKey(string foreignKeyName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | foreignKeyName | The name of the foreign key to create. |
Returns
| Type | Description |
|---|---|
| ICreateForeignKeyFromTableBuilder | An Umbraco.Cms.Infrastructure.Migrations.Expressions.Create.ICreateForeignKeyFromTableBuilder that allows further configuration of the foreign key. |
Index()
Creates and returns a builder for constructing a Create Index expression.
Declaration
public ICreateIndexForTableBuilder Index()
Returns
| Type | Description |
|---|---|
| ICreateIndexForTableBuilder | An Umbraco.Cms.Infrastructure.Migrations.Expressions.Create.ICreateIndexForTableBuilder used to further define the index creation. |
Index(string)
Creates and returns a builder for constructing a Create Index expression with the specified name.
Declaration
public ICreateIndexForTableBuilder Index(string indexName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | indexName | The name of the index to create. |
Returns
| Type | Description |
|---|---|
| ICreateIndexForTableBuilder | An Umbraco.Cms.Infrastructure.Migrations.Expressions.Create.ICreateIndexForTableBuilder used to further define the index creation. |
KeysAndIndexes(Type)
Builds and executes an expression to create keys and indexes for the specified DTO type.
Declaration
public IExecutableBuilder KeysAndIndexes(Type typeOfDto)
Parameters
| Type | Name | Description |
|---|---|---|
| Type | typeOfDto | The System.Type of the DTO for which to create keys and indexes. |
Returns
| Type | Description |
|---|---|
| IExecutableBuilder | An IExecutableBuilder to execute the create keys and indexes expression. |
KeysAndIndexes<TDto>()
Builds a Create Keys and Indexes expression, and executes.
Declaration
public IExecutableBuilder KeysAndIndexes<TDto>()
Returns
| Type | Description |
|---|---|
| IExecutableBuilder |
Type Parameters
| Name | Description |
|---|---|
| TDto |
PrimaryKey()
Builds a Create Primary Key expression.
Declaration
public ICreateConstraintOnTableBuilder PrimaryKey()
Returns
| Type | Description |
|---|---|
| ICreateConstraintOnTableBuilder | An Umbraco.Cms.Infrastructure.Migrations.Expressions.Create.ICreateConstraintOnTableBuilder to further define the primary key constraint. |
PrimaryKey(bool)
Builds a create primary key expression with the option to specify whether it is clustered.
Declaration
public ICreateConstraintOnTableBuilder PrimaryKey(bool clustered)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | clustered | Indicates whether the primary key should be clustered. |
Returns
| Type | Description |
|---|---|
| ICreateConstraintOnTableBuilder | An ICreateConstraintOnTableBuilder to further define the primary key constraint. |
PrimaryKey(string)
Begins building an expression to create a primary key constraint with the specified name.
Declaration
public ICreateConstraintOnTableBuilder PrimaryKey(string primaryKeyName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | primaryKeyName | The name of the primary key constraint to create. |
Returns
| Type | Description |
|---|---|
| ICreateConstraintOnTableBuilder | An Umbraco.Cms.Infrastructure.Migrations.Expressions.Create.ICreateConstraintOnTableBuilder for further configuration of the primary key constraint. |
PrimaryKey(string, bool)
Builds a Create Primary Key expression.
Declaration
public ICreateConstraintOnTableBuilder PrimaryKey(string primaryKeyName, bool clustered)
Parameters
| Type | Name | Description |
|---|---|---|
| string | primaryKeyName | |
| bool | clustered |
Returns
| Type | Description |
|---|---|
| ICreateConstraintOnTableBuilder |
Table(string)
Begins building a CREATE TABLE expression for the specified table.
Declaration
public ICreateTableWithColumnBuilder Table(string tableName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | tableName | The name of the table to create. |
Returns
| Type | Description |
|---|---|
| ICreateTableWithColumnBuilder | An Umbraco.Cms.Infrastructure.Migrations.Expressions.Create.ICreateTableWithColumnBuilder to define columns for the new table. |
Table<TDto>(bool)
Builds a builder for a Create Table expression for the specified DTO type.
Declaration
public IExecutableBuilder Table<TDto>(bool withoutKeysAndIndexes = false)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | withoutKeysAndIndexes | If true, creates the table without keys and indexes. |
Returns
| Type | Description |
|---|---|
| IExecutableBuilder | An IExecutableBuilder to execute the create table expression. |
Type Parameters
| Name | Description |
|---|---|
| TDto | The type representing the table schema. |
UniqueConstraint()
Builds a Create Unique Constraint expression.
Declaration
public ICreateConstraintOnTableBuilder UniqueConstraint()
Returns
| Type | Description |
|---|---|
| ICreateConstraintOnTableBuilder | An Umbraco.Cms.Infrastructure.Migrations.Expressions.Create.ICreateConstraintOnTableBuilder to further define the unique constraint. |
UniqueConstraint(string)
Begins building an expression to create a unique constraint in the database schema.
Declaration
public ICreateConstraintOnTableBuilder UniqueConstraint(string constraintName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | constraintName | The name of the unique constraint to create. |
Returns
| Type | Description |
|---|---|
| ICreateConstraintOnTableBuilder | An ICreateConstraintOnTableBuilder that can be used to further define the unique constraint, such as specifying the table and columns. |