Вроде получилось создать составной первичный ключ для многие ко многим
This commit is contained in:
parent
b29b07baea
commit
7039d958a5
@ -17,6 +17,8 @@ namespace HardwareShopDatabaseImplement
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.Entity<BuildComponent>().HasKey(x => new { x.ComponentId, x.BuildID });
|
||||
modelBuilder.Entity<PurchaseBuild>().HasKey(x => new { x.PurchaseID, x.BuildID });
|
||||
modelBuilder.Entity<PurchaseGood>().HasKey(x => new { x.PurchaseID, x.GoodID });
|
||||
}
|
||||
|
||||
public virtual DbSet<Build> Builds { set; get; }
|
||||
|
336
HardwareShop/HardwareShopDatabaseImplement/Migrations/20230401103551_init.Designer.cs
generated
Normal file
336
HardwareShop/HardwareShopDatabaseImplement/Migrations/20230401103551_init.Designer.cs
generated
Normal file
@ -0,0 +1,336 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using HardwareShopDatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace HardwareShopDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(HardwareShopDatabase))]
|
||||
[Migration("20230401103551_init")]
|
||||
partial class init
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.4")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Build", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("BuildName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<decimal>("Price")
|
||||
.HasColumnType("decimal(18,2)");
|
||||
|
||||
b.Property<int>("UserID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Builds");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.BuildComponent", b =>
|
||||
{
|
||||
b.Property<int>("ComponentId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("BuildID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("BuildId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("ComponentId", "BuildID");
|
||||
|
||||
b.HasIndex("BuildId");
|
||||
|
||||
b.ToTable("BuildComponent");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Comment", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("BuildID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("BuildName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Text")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("BuildID");
|
||||
|
||||
b.ToTable("Comments");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Components");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Good", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Goods");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Purchase", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime?>("DatePurchase")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("PurchaseStatus")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<decimal>("Sum")
|
||||
.HasColumnType("decimal(18,2)");
|
||||
|
||||
b.Property<int>("UserID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserID");
|
||||
|
||||
b.ToTable("Purchase");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.PurchaseBuild", b =>
|
||||
{
|
||||
b.Property<int>("PurchaseID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("BuildID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("BuildId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("PurchaseId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("PurchaseID", "BuildID");
|
||||
|
||||
b.HasIndex("BuildId");
|
||||
|
||||
b.HasIndex("PurchaseId");
|
||||
|
||||
b.ToTable("PurchasesBuilds");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.PurchaseGood", b =>
|
||||
{
|
||||
b.Property<int>("PurchaseID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("GoodID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("PurchaseId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("PurchaseID", "GoodID");
|
||||
|
||||
b.HasIndex("GoodID");
|
||||
|
||||
b.HasIndex("PurchaseId");
|
||||
|
||||
b.ToTable("PurchasesGoods");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.User", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Login")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("Role")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Users");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.BuildComponent", b =>
|
||||
{
|
||||
b.HasOne("HardwareShopDatabaseImplement.Models.Build", "Build")
|
||||
.WithMany("Components")
|
||||
.HasForeignKey("BuildId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("HardwareShopDatabaseImplement.Models.Component", "Component")
|
||||
.WithMany()
|
||||
.HasForeignKey("ComponentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Build");
|
||||
|
||||
b.Navigation("Component");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Comment", b =>
|
||||
{
|
||||
b.HasOne("HardwareShopDatabaseImplement.Models.Build", "Build")
|
||||
.WithMany()
|
||||
.HasForeignKey("BuildID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Build");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Purchase", b =>
|
||||
{
|
||||
b.HasOne("HardwareShopDatabaseImplement.Models.User", "User")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.PurchaseBuild", b =>
|
||||
{
|
||||
b.HasOne("HardwareShopDatabaseImplement.Models.Build", "Build")
|
||||
.WithMany("Purchases")
|
||||
.HasForeignKey("BuildId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("HardwareShopDatabaseImplement.Models.Purchase", "Purchase")
|
||||
.WithMany("Builds")
|
||||
.HasForeignKey("PurchaseId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Build");
|
||||
|
||||
b.Navigation("Purchase");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.PurchaseGood", b =>
|
||||
{
|
||||
b.HasOne("HardwareShopDatabaseImplement.Models.Good", "Good")
|
||||
.WithMany()
|
||||
.HasForeignKey("GoodID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("HardwareShopDatabaseImplement.Models.Purchase", "Purchase")
|
||||
.WithMany("Goods")
|
||||
.HasForeignKey("PurchaseId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Good");
|
||||
|
||||
b.Navigation("Purchase");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Build", b =>
|
||||
{
|
||||
b.Navigation("Components");
|
||||
|
||||
b.Navigation("Purchases");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Purchase", b =>
|
||||
{
|
||||
b.Navigation("Builds");
|
||||
|
||||
b.Navigation("Goods");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,273 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace HardwareShopDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class init : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Builds",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Price = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
|
||||
BuildName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
UserID = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Builds", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Components",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Components", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Goods",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Goods", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Orders",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Orders", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Users",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Login = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Email = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Password = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Role = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Users", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Comments",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Text = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
BuildName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
BuildID = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Comments", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Comments_Builds_BuildID",
|
||||
column: x => x.BuildID,
|
||||
principalTable: "Builds",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "BuildComponent",
|
||||
columns: table => new
|
||||
{
|
||||
BuildID = table.Column<int>(type: "int", nullable: false),
|
||||
ComponentId = table.Column<int>(type: "int", nullable: false),
|
||||
Count = table.Column<int>(type: "int", nullable: false),
|
||||
BuildId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_BuildComponent", x => new { x.ComponentId, x.BuildID });
|
||||
table.ForeignKey(
|
||||
name: "FK_BuildComponent_Builds_BuildId",
|
||||
column: x => x.BuildId,
|
||||
principalTable: "Builds",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_BuildComponent_Components_ComponentId",
|
||||
column: x => x.ComponentId,
|
||||
principalTable: "Components",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Purchase",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Sum = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
|
||||
PurchaseStatus = table.Column<int>(type: "int", nullable: false),
|
||||
DatePurchase = table.Column<DateTime>(type: "datetime2", nullable: true),
|
||||
UserID = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Purchase", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Purchase_Users_UserID",
|
||||
column: x => x.UserID,
|
||||
principalTable: "Users",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "PurchasesBuilds",
|
||||
columns: table => new
|
||||
{
|
||||
BuildID = table.Column<int>(type: "int", nullable: false),
|
||||
PurchaseID = table.Column<int>(type: "int", nullable: false),
|
||||
Count = table.Column<int>(type: "int", nullable: false),
|
||||
BuildId = table.Column<int>(type: "int", nullable: false),
|
||||
PurchaseId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_PurchasesBuilds", x => new { x.PurchaseID, x.BuildID });
|
||||
table.ForeignKey(
|
||||
name: "FK_PurchasesBuilds_Builds_BuildId",
|
||||
column: x => x.BuildId,
|
||||
principalTable: "Builds",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_PurchasesBuilds_Purchase_PurchaseId",
|
||||
column: x => x.PurchaseId,
|
||||
principalTable: "Purchase",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "PurchasesGoods",
|
||||
columns: table => new
|
||||
{
|
||||
PurchaseID = table.Column<int>(type: "int", nullable: false),
|
||||
GoodID = table.Column<int>(type: "int", nullable: false),
|
||||
Count = table.Column<int>(type: "int", nullable: false),
|
||||
PurchaseId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_PurchasesGoods", x => new { x.PurchaseID, x.GoodID });
|
||||
table.ForeignKey(
|
||||
name: "FK_PurchasesGoods_Goods_GoodID",
|
||||
column: x => x.GoodID,
|
||||
principalTable: "Goods",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_PurchasesGoods_Purchase_PurchaseId",
|
||||
column: x => x.PurchaseId,
|
||||
principalTable: "Purchase",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_BuildComponent_BuildId",
|
||||
table: "BuildComponent",
|
||||
column: "BuildId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Comments_BuildID",
|
||||
table: "Comments",
|
||||
column: "BuildID");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Purchase_UserID",
|
||||
table: "Purchase",
|
||||
column: "UserID");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_PurchasesBuilds_BuildId",
|
||||
table: "PurchasesBuilds",
|
||||
column: "BuildId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_PurchasesBuilds_PurchaseId",
|
||||
table: "PurchasesBuilds",
|
||||
column: "PurchaseId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_PurchasesGoods_GoodID",
|
||||
table: "PurchasesGoods",
|
||||
column: "GoodID");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_PurchasesGoods_PurchaseId",
|
||||
table: "PurchasesGoods",
|
||||
column: "PurchaseId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "BuildComponent");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Comments");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Orders");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "PurchasesBuilds");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "PurchasesGoods");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Components");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Builds");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Goods");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Purchase");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Users");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,333 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using HardwareShopDatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace HardwareShopDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(HardwareShopDatabase))]
|
||||
partial class HardwareShopDatabaseModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.4")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Build", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("BuildName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<decimal>("Price")
|
||||
.HasColumnType("decimal(18,2)");
|
||||
|
||||
b.Property<int>("UserID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Builds");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.BuildComponent", b =>
|
||||
{
|
||||
b.Property<int>("ComponentId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("BuildID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("BuildId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("ComponentId", "BuildID");
|
||||
|
||||
b.HasIndex("BuildId");
|
||||
|
||||
b.ToTable("BuildComponent");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Comment", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("BuildID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("BuildName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Text")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("BuildID");
|
||||
|
||||
b.ToTable("Comments");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Components");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Good", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Goods");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Purchase", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime?>("DatePurchase")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("PurchaseStatus")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<decimal>("Sum")
|
||||
.HasColumnType("decimal(18,2)");
|
||||
|
||||
b.Property<int>("UserID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UserID");
|
||||
|
||||
b.ToTable("Purchase");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.PurchaseBuild", b =>
|
||||
{
|
||||
b.Property<int>("PurchaseID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("BuildID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("BuildId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("PurchaseId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("PurchaseID", "BuildID");
|
||||
|
||||
b.HasIndex("BuildId");
|
||||
|
||||
b.HasIndex("PurchaseId");
|
||||
|
||||
b.ToTable("PurchasesBuilds");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.PurchaseGood", b =>
|
||||
{
|
||||
b.Property<int>("PurchaseID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("GoodID")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("PurchaseId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("PurchaseID", "GoodID");
|
||||
|
||||
b.HasIndex("GoodID");
|
||||
|
||||
b.HasIndex("PurchaseId");
|
||||
|
||||
b.ToTable("PurchasesGoods");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.User", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Login")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("Password")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("Role")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Users");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.BuildComponent", b =>
|
||||
{
|
||||
b.HasOne("HardwareShopDatabaseImplement.Models.Build", "Build")
|
||||
.WithMany("Components")
|
||||
.HasForeignKey("BuildId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("HardwareShopDatabaseImplement.Models.Component", "Component")
|
||||
.WithMany()
|
||||
.HasForeignKey("ComponentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Build");
|
||||
|
||||
b.Navigation("Component");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Comment", b =>
|
||||
{
|
||||
b.HasOne("HardwareShopDatabaseImplement.Models.Build", "Build")
|
||||
.WithMany()
|
||||
.HasForeignKey("BuildID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Build");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Purchase", b =>
|
||||
{
|
||||
b.HasOne("HardwareShopDatabaseImplement.Models.User", "User")
|
||||
.WithMany()
|
||||
.HasForeignKey("UserID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.PurchaseBuild", b =>
|
||||
{
|
||||
b.HasOne("HardwareShopDatabaseImplement.Models.Build", "Build")
|
||||
.WithMany("Purchases")
|
||||
.HasForeignKey("BuildId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("HardwareShopDatabaseImplement.Models.Purchase", "Purchase")
|
||||
.WithMany("Builds")
|
||||
.HasForeignKey("PurchaseId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Build");
|
||||
|
||||
b.Navigation("Purchase");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.PurchaseGood", b =>
|
||||
{
|
||||
b.HasOne("HardwareShopDatabaseImplement.Models.Good", "Good")
|
||||
.WithMany()
|
||||
.HasForeignKey("GoodID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("HardwareShopDatabaseImplement.Models.Purchase", "Purchase")
|
||||
.WithMany("Goods")
|
||||
.HasForeignKey("PurchaseId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Good");
|
||||
|
||||
b.Navigation("Purchase");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Build", b =>
|
||||
{
|
||||
b.Navigation("Components");
|
||||
|
||||
b.Navigation("Purchases");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("HardwareShopDatabaseImplement.Models.Purchase", b =>
|
||||
{
|
||||
b.Navigation("Builds");
|
||||
|
||||
b.Navigation("Goods");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -20,8 +20,10 @@ namespace HardwareShopDatabaseImplement.Models
|
||||
|
||||
public virtual User User { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public Dictionary<int, (IBuildModel, int)>? PurchaseBuilds { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public Dictionary<int, (IGoodModel, int)> PurchaseGoods { get; set; } = new();
|
||||
|
||||
|
||||
|
@ -11,12 +11,8 @@ namespace HardwareShopDatabaseImplement.Models
|
||||
public class PurchaseBuild
|
||||
{
|
||||
|
||||
[Key]
|
||||
[Column(Order = 1)]
|
||||
public int BuildID { get; set; }
|
||||
|
||||
[Key]
|
||||
[Column(Order = 2)]
|
||||
public int PurchaseID { get; set; }
|
||||
|
||||
[Required]
|
||||
|
@ -11,12 +11,8 @@ namespace HardwareShopDatabaseImplement.Models
|
||||
public class PurchaseGood
|
||||
{
|
||||
|
||||
[Key]
|
||||
[Column(Order = 1)]
|
||||
public int PurchaseID { get; set; }
|
||||
|
||||
[Key]
|
||||
[Column(Order = 2)]
|
||||
public int GoodID { get; set; }
|
||||
|
||||
[Required]
|
||||
|
Loading…
Reference in New Issue
Block a user