using Microsoft.EntityFrameworkCore.Migrations; namespace DataLayer.Migrations { public partial class NonNullCategory : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.DropForeignKey( name: "FK_Books_Categories_CategoryId", table: "Books"); migrationBuilder.AlterColumn( name: "CategoryId", table: "Books", nullable: false, oldClrType: typeof(int), oldNullable: true); migrationBuilder.AddForeignKey( name: "FK_Books_Categories_CategoryId", table: "Books", column: "CategoryId", principalTable: "Categories", principalColumn: "CategoryId", onDelete: ReferentialAction.Cascade); } protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropForeignKey( name: "FK_Books_Categories_CategoryId", table: "Books"); migrationBuilder.AlterColumn( name: "CategoryId", table: "Books", nullable: true, oldClrType: typeof(int)); migrationBuilder.AddForeignKey( name: "FK_Books_Categories_CategoryId", table: "Books", column: "CategoryId", principalTable: "Categories", principalColumn: "CategoryId", onDelete: ReferentialAction.Restrict); } } }