CourseWork_CompShop/ComputerShopProvider/ComputerShopDatabaseImplement/Migrations/20240517112046_component2.cs

50 lines
1.4 KiB
C#

using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ComputerShopDatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class component2 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "OrderComponents",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
OrderId = table.Column<int>(nullable: false),
ComponentId = table.Column<int>(nullable: false),
Count = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_OrderComponents", x => x.Id);
table.ForeignKey(
name: "FK_OrderComponents_Orders_OrderId",
column: x => x.OrderId,
principalTable: "Orders",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_OrderComponents_Components_ComponentId",
column: x => x.ComponentId,
principalTable: "Components",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "OrderComponents");
}
}
}