SqlServerMigrationSqlGenerator.Generate Method

Definition

Overloads

Generate(MoveTableOperation)

Generates SQL for a MoveTableOperation. Generated SQL should be added using the Statement method.

Generate(RenameColumnOperation)

Generates SQL for a RenameColumnOperation. Generated SQL should be added using the Statement method.

Generate(RenameProcedureOperation)

Generates the specified rename procedure operation.

Generate(RenameTableOperation)

Generates SQL for a RenameTableOperation. Generated SQL should be added using the Statement method.

Generate(SqlOperation)

Generates SQL for a SqlOperation. Generated SQL should be added using the Statement or StatementBatch methods.

Generate(UpdateDatabaseOperation)

Generates the specified update database operation which represents applying a series of migrations. The generated script is idempotent, meaning it contains conditional logic to check if individual migrations have already been applied and only apply the pending ones.

Generate(DbGeography)

Generates SQL to specify a constant geogrpahy default value being set on a column. This method just generates the actual value, not the SQL to set the default value.

Generate(DbGeometry)

Generates SQL to specify a constant geometry default value being set on a column. This method just generates the actual value, not the SQL to set the default value.

Generate(DateTimeOffset)

Generates SQL to specify a constant DateTimeOffset default value being set on a column. This method just generates the actual value, not the SQL to set the default value.

Generate(MoveProcedureOperation)

Generates the specified move procedure operation.

Generate(Guid)

Generates SQL to specify a constant Guid default value being set on a column. This method just generates the actual value, not the SQL to set the default value.

Generate(Object)

Generates SQL to specify a constant default value being set on a column. This method just generates the actual value, not the SQL to set the default value.

Generate(String)

Generates SQL to specify a constant string default value being set on a column. This method just generates the actual value, not the SQL to set the default value.

Generate(TimeSpan)

Generates SQL to specify a constant TimeSpan default value being set on a column. This method just generates the actual value, not the SQL to set the default value.

Generate(IEnumerable<MigrationOperation>, String)

Converts a set of migration operations into Microsoft SQL Server specific SQL.

Generate(ColumnModel, IndentedTextWriter)

Generates SQL for the given column model. This method is called by other methods that process columns and can be overridden to change the SQL generated.

Generate(DateTime)

Generates SQL to specify a constant DateTime default value being set on a column. This method just generates the actual value, not the SQL to set the default value.

Generate(MigrationOperation)

Generates SQL for a MigrationOperation. Allows derived providers to handle additional operation types. Generated SQL should be added using the Statement method.

Generate(RenameIndexOperation)

Generates SQL for a RenameIndexOperation. Generated SQL should be added using the Statement method.

Generate(DropTableOperation)

Generates SQL for a DropTableOperation. Generated SQL should be added using the Statement method.

Generate(Boolean)

Generates SQL to specify a constant bool default value being set on a column. This method just generates the actual value, not the SQL to set the default value.

Generate(Byte[])

Generates SQL to specify a constant byte[] default value being set on a column. This method just generates the actual value, not the SQL to set the default value.

Generate(HistoryOperation)

Generates SQL for a HistoryOperation. Generated SQL should be added using the Statement method.

Generate(AddForeignKeyOperation)

Generates SQL for a AddForeignKeyOperation. Generated SQL should be added using the Statement method.

Generate(AddPrimaryKeyOperation)

Generates SQL for a AddPrimaryKeyOperation. Generated SQL should be added using the Statement method.

Generate(AlterColumnOperation)

Generates SQL for a AlterColumnOperation. Generated SQL should be added using the Statement method.

Generate(AlterProcedureOperation)

Generates the specified alter procedure operation.

Generate(AlterTableOperation)

Override this method to generate SQL when the definition of a table or its attributes are changed. The default implementation of this method does nothing.

Generate(AddColumnOperation)

Generates SQL for a AddColumnOperation. Generated SQL should be added using the Statement method.

Generate(CreateProcedureOperation)

Generates the specified create procedure operation.

Generate(CreateTableOperation)

Generates SQL for a CreateTableOperation. This method differs from WriteCreateTable(CreateTableOperation) in that it will create the target database schema if it does not already exist. Generated SQL should be added using the Statement method.

Generate(DropColumnOperation)

Generates SQL for a DropColumnOperation. Generated SQL should be added using the Statement method.

Generate(DropForeignKeyOperation)

Generates SQL for a DropForeignKeyOperation. Generated SQL should be added using the Statement method.

Generate(DropIndexOperation)

Generates SQL for a DropIndexOperation. Generated SQL should be added using the Statement method.

Generate(CreateIndexOperation)

Generates SQL for a CreateIndexOperation. Generated SQL should be added using the Statement method.

Generate(DropPrimaryKeyOperation)

Generates SQL for a DropPrimaryKeyOperation. Generated SQL should be added using the Statement method.

Generate(DropProcedureOperation)

Generates the specified drop procedure operation.

Generate(MoveTableOperation)

Generates SQL for a MoveTableOperation. Generated SQL should be added using the Statement method.

protected virtual void Generate (System.Data.Entity.Migrations.Model.MoveTableOperation moveTableOperation);
override this.Generate : System.Data.Entity.Migrations.Model.MoveTableOperation -> unit

Parameters

moveTableOperation
MoveTableOperation

The operation to produce SQL for.

Applies to

Generate(RenameColumnOperation)

Generates SQL for a RenameColumnOperation. Generated SQL should be added using the Statement method.

protected virtual void Generate (System.Data.Entity.Migrations.Model.RenameColumnOperation renameColumnOperation);
override this.Generate : System.Data.Entity.Migrations.Model.RenameColumnOperation -> unit

Parameters

renameColumnOperation
RenameColumnOperation

The operation to produce SQL for.

Applies to

Generate(RenameProcedureOperation)

Generates the specified rename procedure operation.

protected virtual void Generate (System.Data.Entity.Migrations.Model.RenameProcedureOperation renameProcedureOperation);
override this.Generate : System.Data.Entity.Migrations.Model.RenameProcedureOperation -> unit

Parameters

renameProcedureOperation
RenameProcedureOperation

The rename procedure operation.

Applies to

Generate(RenameTableOperation)

Generates SQL for a RenameTableOperation. Generated SQL should be added using the Statement method.

protected virtual void Generate (System.Data.Entity.Migrations.Model.RenameTableOperation renameTableOperation);
override this.Generate : System.Data.Entity.Migrations.Model.RenameTableOperation -> unit

Parameters

renameTableOperation
RenameTableOperation

The operation to produce SQL for.

Applies to

Generate(SqlOperation)

Generates SQL for a SqlOperation. Generated SQL should be added using the Statement or StatementBatch methods.

protected virtual void Generate (System.Data.Entity.Migrations.Model.SqlOperation sqlOperation);
override this.Generate : System.Data.Entity.Migrations.Model.SqlOperation -> unit

Parameters

sqlOperation
SqlOperation

The operation to produce SQL for.

Applies to

Generate(UpdateDatabaseOperation)

Generates the specified update database operation which represents applying a series of migrations. The generated script is idempotent, meaning it contains conditional logic to check if individual migrations have already been applied and only apply the pending ones.

protected virtual void Generate (System.Data.Entity.Migrations.Model.UpdateDatabaseOperation updateDatabaseOperation);
override this.Generate : System.Data.Entity.Migrations.Model.UpdateDatabaseOperation -> unit

Parameters

updateDatabaseOperation
UpdateDatabaseOperation

The update database operation.

Applies to

Generate(DbGeography)

Generates SQL to specify a constant geogrpahy default value being set on a column. This method just generates the actual value, not the SQL to set the default value.

protected virtual string Generate (System.Data.Entity.Spatial.DbGeography defaultValue);
override this.Generate : System.Data.Entity.Spatial.DbGeography -> string
Protected Overridable Function Generate (defaultValue As DbGeography) As String

Parameters

defaultValue
DbGeography

The value to be set.

Returns

SQL representing the default value.

Applies to

Generate(DbGeometry)

Generates SQL to specify a constant geometry default value being set on a column. This method just generates the actual value, not the SQL to set the default value.

protected virtual string Generate (System.Data.Entity.Spatial.DbGeometry defaultValue);
override this.Generate : System.Data.Entity.Spatial.DbGeometry -> string
Protected Overridable Function Generate (defaultValue As DbGeometry) As String

Parameters

defaultValue
DbGeometry

The value to be set.

Returns

SQL representing the default value.

Applies to

Generate(DateTimeOffset)

Generates SQL to specify a constant DateTimeOffset default value being set on a column. This method just generates the actual value, not the SQL to set the default value.

protected virtual string Generate (DateTimeOffset defaultValue);
override this.Generate : DateTimeOffset -> string
Protected Overridable Function Generate (defaultValue As DateTimeOffset) As String

Parameters

defaultValue
DateTimeOffset

The value to be set.

Returns

SQL representing the default value.

Applies to

Generate(MoveProcedureOperation)

Generates the specified move procedure operation.

protected virtual void Generate (System.Data.Entity.Migrations.Model.MoveProcedureOperation moveProcedureOperation);
override this.Generate : System.Data.Entity.Migrations.Model.MoveProcedureOperation -> unit

Parameters

moveProcedureOperation
MoveProcedureOperation

The move procedure operation.

Applies to

Generate(Guid)

Generates SQL to specify a constant Guid default value being set on a column. This method just generates the actual value, not the SQL to set the default value.

protected virtual string Generate (Guid defaultValue);
override this.Generate : Guid -> string
Protected Overridable Function Generate (defaultValue As Guid) As String

Parameters

defaultValue
Guid

The value to be set.

Returns

SQL representing the default value.

Applies to

Generate(Object)

Generates SQL to specify a constant default value being set on a column. This method just generates the actual value, not the SQL to set the default value.

protected virtual string Generate (object defaultValue);
override this.Generate : obj -> string
Protected Overridable Function Generate (defaultValue As Object) As String

Parameters

defaultValue
Object

The value to be set.

Returns

SQL representing the default value.

Applies to

Generate(String)

Generates SQL to specify a constant string default value being set on a column. This method just generates the actual value, not the SQL to set the default value.

protected virtual string Generate (string defaultValue);
override this.Generate : string -> string
Protected Overridable Function Generate (defaultValue As String) As String

Parameters

defaultValue
String

The value to be set.

Returns

SQL representing the default value.

Applies to

Generate(TimeSpan)

Generates SQL to specify a constant TimeSpan default value being set on a column. This method just generates the actual value, not the SQL to set the default value.

protected virtual string Generate (TimeSpan defaultValue);
override this.Generate : TimeSpan -> string
Protected Overridable Function Generate (defaultValue As TimeSpan) As String

Parameters

defaultValue
TimeSpan

The value to be set.

Returns

SQL representing the default value.

Applies to

Generate(IEnumerable<MigrationOperation>, String)

Converts a set of migration operations into Microsoft SQL Server specific SQL.

public override System.Collections.Generic.IEnumerable<System.Data.Entity.Migrations.Sql.MigrationStatement> Generate (System.Collections.Generic.IEnumerable<System.Data.Entity.Migrations.Model.MigrationOperation> migrationOperations, string providerManifestToken);
override this.Generate : seq<System.Data.Entity.Migrations.Model.MigrationOperation> * string -> seq<System.Data.Entity.Migrations.Sql.MigrationStatement>
Public Overrides Function Generate (migrationOperations As IEnumerable(Of MigrationOperation), providerManifestToken As String) As IEnumerable(Of MigrationStatement)

Parameters

migrationOperations
IEnumerable<MigrationOperation>

The operations to be converted.

providerManifestToken
String

Token representing the version of SQL Server being targeted (i.e. "2005", "2008").

Returns

A list of SQL statements to be executed to perform the migration operations.

Applies to

Generate(ColumnModel, IndentedTextWriter)

Generates SQL for the given column model. This method is called by other methods that process columns and can be overridden to change the SQL generated.

protected internal virtual void Generate (System.Data.Entity.Migrations.Model.ColumnModel column, System.Data.Entity.Migrations.Utilities.IndentedTextWriter writer);
override this.Generate : System.Data.Entity.Migrations.Model.ColumnModel * System.Data.Entity.Migrations.Utilities.IndentedTextWriter -> unit
Protected Friend Overridable Sub Generate (column As ColumnModel, writer As IndentedTextWriter)

Parameters

column
ColumnModel

The column for which SQL is being generated.

writer
IndentedTextWriter

The writer to which generated SQL should be written.

Applies to

Generate(DateTime)

Generates SQL to specify a constant DateTime default value being set on a column. This method just generates the actual value, not the SQL to set the default value.

protected virtual string Generate (DateTime defaultValue);
override this.Generate : DateTime -> string
Protected Overridable Function Generate (defaultValue As DateTime) As String

Parameters

defaultValue
DateTime

The value to be set.

Returns

SQL representing the default value.

Applies to

Generate(MigrationOperation)

Generates SQL for a MigrationOperation. Allows derived providers to handle additional operation types. Generated SQL should be added using the Statement method.

protected virtual void Generate (System.Data.Entity.Migrations.Model.MigrationOperation migrationOperation);
override this.Generate : System.Data.Entity.Migrations.Model.MigrationOperation -> unit

Parameters

migrationOperation
MigrationOperation

The operation to produce SQL for.

Applies to

Generate(RenameIndexOperation)

Generates SQL for a RenameIndexOperation. Generated SQL should be added using the Statement method.

protected virtual void Generate (System.Data.Entity.Migrations.Model.RenameIndexOperation renameIndexOperation);
override this.Generate : System.Data.Entity.Migrations.Model.RenameIndexOperation -> unit

Parameters

renameIndexOperation
RenameIndexOperation

The operation to produce SQL for.

Applies to

Generate(DropTableOperation)

Generates SQL for a DropTableOperation. Generated SQL should be added using the Statement method.

protected virtual void Generate (System.Data.Entity.Migrations.Model.DropTableOperation dropTableOperation);
override this.Generate : System.Data.Entity.Migrations.Model.DropTableOperation -> unit

Parameters

dropTableOperation
DropTableOperation

The operation to produce SQL for.

Applies to

Generate(Boolean)

Generates SQL to specify a constant bool default value being set on a column. This method just generates the actual value, not the SQL to set the default value.

protected virtual string Generate (bool defaultValue);
override this.Generate : bool -> string
Protected Overridable Function Generate (defaultValue As Boolean) As String

Parameters

defaultValue
Boolean

The value to be set.

Returns

SQL representing the default value.

Applies to

Generate(Byte[])

Generates SQL to specify a constant byte[] default value being set on a column. This method just generates the actual value, not the SQL to set the default value.

protected virtual string Generate (byte[] defaultValue);
override this.Generate : byte[] -> string
Protected Overridable Function Generate (defaultValue As Byte()) As String

Parameters

defaultValue
Byte[]

The value to be set.

Returns

SQL representing the default value.

Applies to

Generate(HistoryOperation)

Generates SQL for a HistoryOperation. Generated SQL should be added using the Statement method.

protected virtual void Generate (System.Data.Entity.Migrations.Model.HistoryOperation historyOperation);
override this.Generate : System.Data.Entity.Migrations.Model.HistoryOperation -> unit

Parameters

historyOperation
HistoryOperation

The operation to produce SQL for.

Applies to

Generate(AddForeignKeyOperation)

Generates SQL for a AddForeignKeyOperation. Generated SQL should be added using the Statement method.

protected virtual void Generate (System.Data.Entity.Migrations.Model.AddForeignKeyOperation addForeignKeyOperation);
override this.Generate : System.Data.Entity.Migrations.Model.AddForeignKeyOperation -> unit

Parameters

addForeignKeyOperation
AddForeignKeyOperation

The operation to produce SQL for.

Applies to

Generate(AddPrimaryKeyOperation)

Generates SQL for a AddPrimaryKeyOperation. Generated SQL should be added using the Statement method.

protected virtual void Generate (System.Data.Entity.Migrations.Model.AddPrimaryKeyOperation addPrimaryKeyOperation);
override this.Generate : System.Data.Entity.Migrations.Model.AddPrimaryKeyOperation -> unit

Parameters

addPrimaryKeyOperation
AddPrimaryKeyOperation

The operation to produce SQL for.

Applies to

Generate(AlterColumnOperation)

Generates SQL for a AlterColumnOperation. Generated SQL should be added using the Statement method.

protected virtual void Generate (System.Data.Entity.Migrations.Model.AlterColumnOperation alterColumnOperation);
override this.Generate : System.Data.Entity.Migrations.Model.AlterColumnOperation -> unit

Parameters

alterColumnOperation
AlterColumnOperation

The operation to produce SQL for.

Applies to

Generate(AlterProcedureOperation)

Generates the specified alter procedure operation.

protected virtual void Generate (System.Data.Entity.Migrations.Model.AlterProcedureOperation alterProcedureOperation);
override this.Generate : System.Data.Entity.Migrations.Model.AlterProcedureOperation -> unit

Parameters

alterProcedureOperation
AlterProcedureOperation

The alter procedure operation.

Applies to

Generate(AlterTableOperation)

Override this method to generate SQL when the definition of a table or its attributes are changed. The default implementation of this method does nothing.

protected internal virtual void Generate (System.Data.Entity.Migrations.Model.AlterTableOperation alterTableOperation);
override this.Generate : System.Data.Entity.Migrations.Model.AlterTableOperation -> unit

Parameters

alterTableOperation
AlterTableOperation

The operation describing changes to the table.

Applies to

Generate(AddColumnOperation)

Generates SQL for a AddColumnOperation. Generated SQL should be added using the Statement method.

protected virtual void Generate (System.Data.Entity.Migrations.Model.AddColumnOperation addColumnOperation);
override this.Generate : System.Data.Entity.Migrations.Model.AddColumnOperation -> unit

Parameters

addColumnOperation
AddColumnOperation

The operation to produce SQL for.

Applies to

Generate(CreateProcedureOperation)

Generates the specified create procedure operation.

protected virtual void Generate (System.Data.Entity.Migrations.Model.CreateProcedureOperation createProcedureOperation);
override this.Generate : System.Data.Entity.Migrations.Model.CreateProcedureOperation -> unit

Parameters

createProcedureOperation
CreateProcedureOperation

The create procedure operation.

Applies to

Generate(CreateTableOperation)

Generates SQL for a CreateTableOperation. This method differs from WriteCreateTable(CreateTableOperation) in that it will create the target database schema if it does not already exist. Generated SQL should be added using the Statement method.

protected virtual void Generate (System.Data.Entity.Migrations.Model.CreateTableOperation createTableOperation);
override this.Generate : System.Data.Entity.Migrations.Model.CreateTableOperation -> unit

Parameters

createTableOperation
CreateTableOperation

The operation to produce SQL for.

Applies to

Generate(DropColumnOperation)

Generates SQL for a DropColumnOperation. Generated SQL should be added using the Statement method.

protected virtual void Generate (System.Data.Entity.Migrations.Model.DropColumnOperation dropColumnOperation);
override this.Generate : System.Data.Entity.Migrations.Model.DropColumnOperation -> unit

Parameters

dropColumnOperation
DropColumnOperation

The operation to produce SQL for.

Applies to

Generate(DropForeignKeyOperation)

Generates SQL for a DropForeignKeyOperation. Generated SQL should be added using the Statement method.

protected virtual void Generate (System.Data.Entity.Migrations.Model.DropForeignKeyOperation dropForeignKeyOperation);
override this.Generate : System.Data.Entity.Migrations.Model.DropForeignKeyOperation -> unit

Parameters

dropForeignKeyOperation
DropForeignKeyOperation

The operation to produce SQL for.

Applies to

Generate(DropIndexOperation)

Generates SQL for a DropIndexOperation. Generated SQL should be added using the Statement method.

protected virtual void Generate (System.Data.Entity.Migrations.Model.DropIndexOperation dropIndexOperation);
override this.Generate : System.Data.Entity.Migrations.Model.DropIndexOperation -> unit

Parameters

dropIndexOperation
DropIndexOperation

The operation to produce SQL for.

Applies to

Generate(CreateIndexOperation)

Generates SQL for a CreateIndexOperation. Generated SQL should be added using the Statement method.

protected virtual void Generate (System.Data.Entity.Migrations.Model.CreateIndexOperation createIndexOperation);
override this.Generate : System.Data.Entity.Migrations.Model.CreateIndexOperation -> unit

Parameters

createIndexOperation
CreateIndexOperation

The operation to produce SQL for.

Applies to

Generate(DropPrimaryKeyOperation)

Generates SQL for a DropPrimaryKeyOperation. Generated SQL should be added using the Statement method.

protected virtual void Generate (System.Data.Entity.Migrations.Model.DropPrimaryKeyOperation dropPrimaryKeyOperation);
override this.Generate : System.Data.Entity.Migrations.Model.DropPrimaryKeyOperation -> unit

Parameters

dropPrimaryKeyOperation
DropPrimaryKeyOperation

The operation to produce SQL for.

Applies to

Generate(DropProcedureOperation)

Generates the specified drop procedure operation.

protected virtual void Generate (System.Data.Entity.Migrations.Model.DropProcedureOperation dropProcedureOperation);
override this.Generate : System.Data.Entity.Migrations.Model.DropProcedureOperation -> unit

Parameters

dropProcedureOperation
DropProcedureOperation

The drop procedure operation.

Applies to