Exemplo n.º 1
0
        private string GenerateSqlStatementConcrete(AddPrimaryKeyOperation migrationOperation)
        {
            JetDdlBuilder ddlBuilder = new JetDdlBuilder();

            ddlBuilder.AppendSql("ALTER TABLE ");
            ddlBuilder.AppendIdentifier(migrationOperation.Table);
            ddlBuilder.AppendSql(" ADD CONSTRAINT ");

            // respect name given to primary keys in migrations
            string pkName = migrationOperation.HasDefaultName ?
                            ddlBuilder.CreateConstraintName("PK", migrationOperation.Table) : // Take care because here names starts with "dbo."
                            migrationOperation.Name;

            ddlBuilder.AppendIdentifier(pkName);
            ddlBuilder.AppendSql(" PRIMARY KEY (");
            ddlBuilder.AppendIdentifierList(migrationOperation.Columns);
            ddlBuilder.AppendSql(")");
            return(ddlBuilder.GetCommandText());
        }