using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace Casestudy.Migrations { /// <inheritdoc /> public partial class orders : Migration { /// <inheritdoc /> protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Order", columns: table => new { Id = table.Column<int>(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), OrderDate = table.Column<DateTime>(type: "datetime2", nullable: false), OrderAmount = table.Column<decimal>(type: "money", nullable: false), CustomerId = table.Column<int>(type: "int", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Order", x => x.Id); table.ForeignKey( name: "FK_Order_Customers_CustomerId", column: x => x.CustomerId, principalTable: "Customers", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "OrderLineItem", columns: table => new { Id = table.Column<int>(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), OrderId = table.Column<int>(type: "int", nullable: false), ProductId = table.Column<string>(type: "nvarchar(450)", nullable: false), QtyOrdered = table.Column<int>(type: "int", nullable: false), QtySold = table.Column<int>(type: "int", nullable: false), QtyBackOrdered = table.Column<int>(type: "int", nullable: false), SellingPrice = table.Column<decimal>(type: "money", nullable: false) }, constraints: table => { table.PrimaryKey("PK_OrderLineItem", x => x.Id); table.ForeignKey( name: "FK_OrderLineItem_Order_OrderId", column: x => x.OrderId, principalTable: "Order", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_OrderLineItem_Products_ProductId", column: x => x.ProductId, principalTable: "Products", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_Order_CustomerId", table: "Order", column: "CustomerId"); migrationBuilder.CreateIndex( name: "IX_OrderLineItem_OrderId", table: "OrderLineItem", column: "OrderId"); migrationBuilder.CreateIndex( name: "IX_OrderLineItem_ProductId", table: "OrderLineItem", column: "ProductId"); } /// <inheritdoc /> protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "OrderLineItem"); migrationBuilder.DropTable( name: "Order"); } } }