src/EntityFramework/Migrations/Design/CSharpMigrationCodeGenerator.cs
/// <summary>
/// Generates code to perform an <see cref="AddPrimaryKeyOperation" />.
/// </summary>
/// <param name="addPrimaryKeyOperation"> The operation to generate code for. </param>
/// <param name="writer"> Text writer to add the generated code to. </param>
Generates code to perform an .
Generates code to perform an .
protected virtual void Generate(AddPrimaryKeyOperation addPrimaryKeyOperation, IndentedTextWriter writer)
        {
            Check.NotNull(addPrimaryKeyOperation, "addPrimaryKeyOperation");
            Check.NotNull(writer, "writer");
            writer.Write("AddPrimaryKey(");
            writer.Write(Quote(addPrimaryKeyOperation.Table));
            writer.Write(", ");
            var compositeKey = addPrimaryKeyOperation.Columns.Count() > 1;
            if (compositeKey)
            {
                writer.Write("new[] { ");
            }
            writer.Write(addPrimaryKeyOperation.Columns.Join(Quote));
            if (compositeKey)
            {
                writer.Write(" }");
            }
            if (!addPrimaryKeyOperation.HasDefaultName)
            {
                writer.Write(", name: ");
                writer.Write(Quote(addPrimaryKeyOperation.Name));
            }
            if (!addPrimaryKeyOperation.IsClustered)
            {
                writer.Write(", clustered: false");
            }
            writer.WriteLine(");");
        }
protected virtual void Generate ( AddPrimaryKeyOperation addPrimaryKeyOperation , IndentedTextWriter writer ) { Check . NotNull ( addPrimaryKeyOperation , " " ) ; Check . NotNull ( writer , " " ) ; writer . Write ( " " ) ; writer . Write ( Quote ( addPrimaryKeyOperation . Table ) ) ; writer . Write ( " " ) ; var compositeKey = addPrimaryKeyOperation . Columns . Count ( ) > 1 ; if ( compositeKey ) { writer . Write ( " " ) ; } writer . Write ( addPrimaryKeyOperation . Columns . Join ( Quote ) ) ; if ( compositeKey ) { writer . Write ( " " ) ; } if ( ! addPrimaryKeyOperation . HasDefaultName ) { writer . Write ( " " ) ; writer . Write ( Quote ( addPrimaryKeyOperation . Name ) ) ; } if ( ! addPrimaryKeyOperation . IsClustered ) { writer . Write ( " " ) ; } writer . WriteLine ( " " ) ; }
Generates code to perform an .
Generates code to perform an .
addPrimaryKeyOperation
AddPrimaryKeyOperation
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 .