migrationBuilder.AlterColumn<int>( name: "Id", table: "PrimaryKeyTable", nullable: false, oldClrType: typeof(int), oldType: "int") .Annotation("SqlServer:Identity", "0, 1");
/* Add new identity column */ migrationBuilder.AddColumn<int>( name: "NewId", table: "PrimaryKeyTable", nullable: false ) .Annotation("SqlServer:Identity", "1, 1"); /* Remove foreign keys against the old PK field */ migrationBuilder.DropForeignKey( name: "FK_ForeignKeyTable_PrimaryKeyTable_RaceId", table: "ForeignKeyTable" ); /* Drop Primary Key */ migrationBuilder.DropPrimaryKey( name: "PK_PrimaryKeyTable", table: "PrimaryKeyTable" ); /* Drop Old Column */ migrationBuilder.DropColumn( name: "Id", table: "PrimaryKeyTable" ); /* Rename New Column*/ migrationBuilder.RenameColumn( name: "NewId", table: "PrimaryKeyTable", newName: "Id"); /* Add Primary Key back */ migrationBuilder.AddPrimaryKey( name: "PK_PrimaryKeyTable", table: "PrimaryKeyTable", column: "Id" ); /* Add Foreign Keys back */ migrationBuilder.AddForeignKey( name: "FK_ForeignKeyTable_PrimaryKeyTable_RaceId", table: "ForeignKeyTable", column: "RaceId", principalTable: "PrimaryKeyTable", principalColumn: "Id", onDelete: ReferentialAction.Restrict );
ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2024, Patrick Jasinski.