using System; using Microsoft.EntityFrameworkCore.Migrations; namespace work_01.Migrations { public partial class ScriptA : Migration { protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Customers", columns: table => new { CustomerId = table.Column(nullable: false) .Annotation("SqlServer:Identity", "1, 1"), CustomerName = table.Column(maxLength: 50, nullable: false), Address = table.Column(nullable: false), Mobile = table.Column(nullable: false) }, constraints: table => { table.PrimaryKey("PK_Customers", x => x.CustomerId); }); migrationBuilder.CreateTable( name: "Cars", columns: table => new { CarId = table.Column(nullable: false) .Annotation("SqlServer:Identity", "1, 1"), CarName = table.Column(maxLength: 30, nullable: false), CustomerId = table.Column(nullable: false), Make = table.Column(nullable: false), PurchaseDate = table.Column(type: "date", nullable: false), Price = table.Column(type: "money", nullable: false), isAvailable = table.Column(nullable: false), PicturePath = table.Column(nullable: true) }, constraints: table => { table.PrimaryKey("PK_Cars", x => x.CarId); table.ForeignKey( name: "FK_Cars_Customers_CustomerId", column: x => x.CustomerId, principalTable: "Customers", principalColumn: "CustomerId", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_Cars_CustomerId", table: "Cars", column: "CustomerId"); } protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "Cars"); migrationBuilder.DropTable( name: "Customers"); } } }