src/EntityFramework/Migrations/Design/CSharpMigrationCodeGenerator.cs
/// <summary>
/// Generates code to perform a <see cref="DropForeignKeyOperation" />.
/// </summary>
/// <param name="dropForeignKeyOperation"> The operation to generate code for. </param>
/// <param name="writer"> Text writer to add the generated code to. </param>
Generates code to perform a .
Generates code to perform a .
protected virtual void Generate(DropForeignKeyOperation dropForeignKeyOperation, IndentedTextWriter writer)
        {
            Check.NotNull(dropForeignKeyOperation, "dropForeignKeyOperation");
            Check.NotNull(writer, "writer");
            writer.Write("DropForeignKey(");
            writer.Write(Quote(dropForeignKeyOperation.DependentTable));
            writer.Write(", ");
            if (!dropForeignKeyOperation.HasDefaultName)
            {
                writer.Write(Quote(dropForeignKeyOperation.Name));
            }
            else
            {
                var compositeKey = dropForeignKeyOperation.DependentColumns.Count() > 1;
                if (compositeKey)
                {
                    writer.Write("new[] { ");
                }
                writer.Write(dropForeignKeyOperation.DependentColumns.Join(Quote));
                if (compositeKey)
                {
                    writer.Write(" }");
                }
                writer.Write(", ");
                writer.Write(Quote(dropForeignKeyOperation.PrincipalTable));
            }
            writer.WriteLine(");");
        }
protected virtual void Generate ( DropForeignKeyOperation dropForeignKeyOperation , IndentedTextWriter writer ) { Check . NotNull ( dropForeignKeyOperation , " " ) ; Check . NotNull ( writer , " " ) ; writer . Write ( " " ) ; writer . Write ( Quote ( dropForeignKeyOperation . DependentTable ) ) ; writer . Write ( " " ) ; if ( ! dropForeignKeyOperation . HasDefaultName ) { writer . Write ( Quote ( dropForeignKeyOperation . Name ) ) ; } else { var compositeKey = dropForeignKeyOperation . DependentColumns . Count ( ) > 1 ; if ( compositeKey ) { writer . Write ( " " ) ; } writer . Write ( dropForeignKeyOperation . DependentColumns . Join ( Quote ) ) ; if ( compositeKey ) { writer . Write ( " " ) ; } writer . Write ( " " ) ; writer . Write ( Quote ( dropForeignKeyOperation . PrincipalTable ) ) ; } writer . WriteLine ( " " ) ; }
Generates code to perform a .
Generates code to perform a .
dropForeignKeyOperation
DropForeignKeyOperation
The operation to generate code for.
The operation to generate code for .
writer
IndentedTextWriter
Text writer to add the generated code to.
Text writer to add the generated code to .