using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace WebVentaCoche.Migrations { /// public partial class OrdersOrderDetails : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "OrderDetailViewModel"); migrationBuilder.CreateTable( name: "OrderDetails", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), OrderId = table.Column(type: "int", nullable: false), ProductId = table.Column(type: "int", nullable: false), Quantity = table.Column(type: "int", nullable: false), UnitPrice = table.Column(type: "decimal(18,2)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_OrderDetails", x => x.Id); table.ForeignKey( name: "FK_OrderDetails_Orders_OrderId", column: x => x.OrderId, principalTable: "Orders", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_OrderDetails_Products_ProductId", column: x => x.ProductId, principalTable: "Products", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_OrderDetails_OrderId", table: "OrderDetails", column: "OrderId"); migrationBuilder.CreateIndex( name: "IX_OrderDetails_ProductId", table: "OrderDetails", column: "ProductId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "OrderDetails"); migrationBuilder.CreateTable( name: "OrderDetailViewModel", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), OrderId = table.Column(type: "int", nullable: false), ProductId = table.Column(type: "int", nullable: false), Quantity = table.Column(type: "int", nullable: false), UnitPrice = table.Column(type: "decimal(18,2)", nullable: false) }, constraints: table => { table.PrimaryKey("PK_OrderDetailViewModel", x => x.Id); table.ForeignKey( name: "FK_OrderDetailViewModel_Orders_OrderId", column: x => x.OrderId, principalTable: "Orders", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_OrderDetailViewModel_Products_ProductId", column: x => x.ProductId, principalTable: "Products", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_OrderDetailViewModel_OrderId", table: "OrderDetailViewModel", column: "OrderId"); migrationBuilder.CreateIndex( name: "IX_OrderDetailViewModel_ProductId", table: "OrderDetailViewModel", column: "ProductId"); } } }