Database updated with client

This commit is contained in:
the 2023-04-07 17:55:39 +04:00
parent 9f9aa560c3
commit 754a533e7a
3 changed files with 784 additions and 0 deletions

View File

@ -0,0 +1,506 @@
// <auto-generated />
using System;
using ComputerShopDatabaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace ComputerShopDatabaseImplement.Migrations
{
[DbContext(typeof(ComputerShopDatabase))]
[Migration("20230407135446_clientmigration")]
partial class clientmigration
{
/// <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("ComputerShopDatabaseImplement.Models.Assembly", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("AssemblyName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int?>("ClientId")
.HasColumnType("int");
b.Property<double>("Price")
.HasColumnType("float");
b.HasKey("Id");
b.HasIndex("ClientId");
b.ToTable("Assemblies");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.AssemblyComponent", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("AssemblyId")
.HasColumnType("int");
b.Property<int>("ComponentId")
.HasColumnType("int");
b.Property<int>("Count")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("AssemblyId");
b.HasIndex("ComponentId");
b.ToTable("AssemblyComponents");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.AssemblyOrder", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("AssemblyId")
.HasColumnType("int");
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int>("OrderId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("AssemblyId");
b.HasIndex("OrderId");
b.ToTable("AssemblyOrders");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Client", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ClientFIO")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Clients");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Component", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ComponentName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<double>("Cost")
.HasColumnType("float");
b.HasKey("Id");
b.ToTable("Components");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.ComponentSupply", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("ComponentId")
.HasColumnType("int");
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int>("SupplyId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ComponentId");
b.HasIndex("SupplyId");
b.ToTable("ComponentSupplies");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.EquipmentReceiving", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int?>("ClientId")
.HasColumnType("int");
b.Property<DateTime?>("DateImplement")
.HasColumnType("datetime2");
b.Property<int>("Status")
.HasColumnType("int");
b.Property<int?>("SupplyId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ClientId");
b.HasIndex("SupplyId");
b.ToTable("EquipmentReceivings");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Order", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int?>("ClientId")
.HasColumnType("int");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateImplement")
.HasColumnType("datetime2");
b.Property<int>("Status")
.HasColumnType("int");
b.Property<double>("Sum")
.HasColumnType("float");
b.HasKey("Id");
b.HasIndex("ClientId");
b.ToTable("Orders");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Purchase", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int?>("ClientId")
.HasColumnType("int");
b.Property<int>("ComponentId")
.HasColumnType("int");
b.Property<string>("ComponentName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("Count")
.HasColumnType("int");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateImplement")
.HasColumnType("datetime2");
b.Property<int>("Status")
.HasColumnType("int");
b.Property<double>("Sum")
.HasColumnType("float");
b.HasKey("Id");
b.HasIndex("ClientId");
b.HasIndex("ComponentId");
b.ToTable("Purchases");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Supply", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int?>("ClientId")
.HasColumnType("int");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateImplement")
.HasColumnType("datetime2");
b.Property<int>("OrderId")
.HasColumnType("int");
b.Property<int>("ReceivingId")
.HasColumnType("int");
b.Property<int>("Status")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ClientId");
b.ToTable("Supplies");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.SupplyOrder", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int>("OrderId")
.HasColumnType("int");
b.Property<int>("SupplyId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("OrderId");
b.HasIndex("SupplyId");
b.ToTable("SupplyOrders");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Assembly", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Client", null)
.WithMany("Assemblies")
.HasForeignKey("ClientId");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.AssemblyComponent", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Assembly", "Assembly")
.WithMany("Components")
.HasForeignKey("AssemblyId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ComputerShopDatabaseImplement.Models.Component", "Component")
.WithMany("AssemblyComponents")
.HasForeignKey("ComponentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Assembly");
b.Navigation("Component");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.AssemblyOrder", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Assembly", "Assembly")
.WithMany("Orders")
.HasForeignKey("AssemblyId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ComputerShopDatabaseImplement.Models.Order", "Order")
.WithMany("Assemblies")
.HasForeignKey("OrderId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Assembly");
b.Navigation("Order");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.ComponentSupply", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Component", "Component")
.WithMany("Supplies")
.HasForeignKey("ComponentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ComputerShopDatabaseImplement.Models.Supply", "Supply")
.WithMany("Supplies")
.HasForeignKey("SupplyId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Component");
b.Navigation("Supply");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.EquipmentReceiving", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Client", null)
.WithMany("EquipmentReceivings")
.HasForeignKey("ClientId");
b.HasOne("ComputerShopDatabaseImplement.Models.Supply", null)
.WithMany("Receivings")
.HasForeignKey("SupplyId");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Order", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Client", null)
.WithMany("Orders")
.HasForeignKey("ClientId");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Purchase", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Client", null)
.WithMany("Purchases")
.HasForeignKey("ClientId");
b.HasOne("ComputerShopDatabaseImplement.Models.Component", "Component")
.WithMany("Purchases")
.HasForeignKey("ComponentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Component");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Supply", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Client", null)
.WithMany("Supplies")
.HasForeignKey("ClientId");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.SupplyOrder", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Order", "Order")
.WithMany("SupplyOrders")
.HasForeignKey("OrderId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ComputerShopDatabaseImplement.Models.Supply", "Supply")
.WithMany("Orders")
.HasForeignKey("SupplyId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Order");
b.Navigation("Supply");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Assembly", b =>
{
b.Navigation("Components");
b.Navigation("Orders");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Client", b =>
{
b.Navigation("Assemblies");
b.Navigation("EquipmentReceivings");
b.Navigation("Orders");
b.Navigation("Purchases");
b.Navigation("Supplies");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Component", b =>
{
b.Navigation("AssemblyComponents");
b.Navigation("Purchases");
b.Navigation("Supplies");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Order", b =>
{
b.Navigation("Assemblies");
b.Navigation("SupplyOrders");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Supply", b =>
{
b.Navigation("Orders");
b.Navigation("Receivings");
b.Navigation("Supplies");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,186 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ComputerShopDatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class clientmigration : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "ClientId",
table: "Supplies",
type: "int",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "ClientId",
table: "Purchases",
type: "int",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "ClientId",
table: "Orders",
type: "int",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "ClientId",
table: "EquipmentReceivings",
type: "int",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "ClientId",
table: "Assemblies",
type: "int",
nullable: true);
migrationBuilder.CreateTable(
name: "Clients",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ClientFIO = 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)
},
constraints: table =>
{
table.PrimaryKey("PK_Clients", x => x.Id);
});
migrationBuilder.CreateIndex(
name: "IX_Supplies_ClientId",
table: "Supplies",
column: "ClientId");
migrationBuilder.CreateIndex(
name: "IX_Purchases_ClientId",
table: "Purchases",
column: "ClientId");
migrationBuilder.CreateIndex(
name: "IX_Orders_ClientId",
table: "Orders",
column: "ClientId");
migrationBuilder.CreateIndex(
name: "IX_EquipmentReceivings_ClientId",
table: "EquipmentReceivings",
column: "ClientId");
migrationBuilder.CreateIndex(
name: "IX_Assemblies_ClientId",
table: "Assemblies",
column: "ClientId");
migrationBuilder.AddForeignKey(
name: "FK_Assemblies_Clients_ClientId",
table: "Assemblies",
column: "ClientId",
principalTable: "Clients",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_EquipmentReceivings_Clients_ClientId",
table: "EquipmentReceivings",
column: "ClientId",
principalTable: "Clients",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Orders_Clients_ClientId",
table: "Orders",
column: "ClientId",
principalTable: "Clients",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Purchases_Clients_ClientId",
table: "Purchases",
column: "ClientId",
principalTable: "Clients",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_Supplies_Clients_ClientId",
table: "Supplies",
column: "ClientId",
principalTable: "Clients",
principalColumn: "Id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Assemblies_Clients_ClientId",
table: "Assemblies");
migrationBuilder.DropForeignKey(
name: "FK_EquipmentReceivings_Clients_ClientId",
table: "EquipmentReceivings");
migrationBuilder.DropForeignKey(
name: "FK_Orders_Clients_ClientId",
table: "Orders");
migrationBuilder.DropForeignKey(
name: "FK_Purchases_Clients_ClientId",
table: "Purchases");
migrationBuilder.DropForeignKey(
name: "FK_Supplies_Clients_ClientId",
table: "Supplies");
migrationBuilder.DropTable(
name: "Clients");
migrationBuilder.DropIndex(
name: "IX_Supplies_ClientId",
table: "Supplies");
migrationBuilder.DropIndex(
name: "IX_Purchases_ClientId",
table: "Purchases");
migrationBuilder.DropIndex(
name: "IX_Orders_ClientId",
table: "Orders");
migrationBuilder.DropIndex(
name: "IX_EquipmentReceivings_ClientId",
table: "EquipmentReceivings");
migrationBuilder.DropIndex(
name: "IX_Assemblies_ClientId",
table: "Assemblies");
migrationBuilder.DropColumn(
name: "ClientId",
table: "Supplies");
migrationBuilder.DropColumn(
name: "ClientId",
table: "Purchases");
migrationBuilder.DropColumn(
name: "ClientId",
table: "Orders");
migrationBuilder.DropColumn(
name: "ClientId",
table: "EquipmentReceivings");
migrationBuilder.DropColumn(
name: "ClientId",
table: "Assemblies");
}
}
}

View File

@ -34,11 +34,16 @@ namespace ComputerShopDatabaseImplement.Migrations
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int?>("ClientId")
.HasColumnType("int");
b.Property<double>("Price")
.HasColumnType("float");
b.HasKey("Id");
b.HasIndex("ClientId");
b.ToTable("Assemblies");
});
@ -94,6 +99,31 @@ namespace ComputerShopDatabaseImplement.Migrations
b.ToTable("AssemblyOrders");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Client", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ClientFIO")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Clients");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Component", b =>
{
b.Property<int>("Id")
@ -148,6 +178,9 @@ namespace ComputerShopDatabaseImplement.Migrations
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int?>("ClientId")
.HasColumnType("int");
b.Property<DateTime?>("DateImplement")
.HasColumnType("datetime2");
@ -159,6 +192,8 @@ namespace ComputerShopDatabaseImplement.Migrations
b.HasKey("Id");
b.HasIndex("ClientId");
b.HasIndex("SupplyId");
b.ToTable("EquipmentReceivings");
@ -172,6 +207,9 @@ namespace ComputerShopDatabaseImplement.Migrations
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int?>("ClientId")
.HasColumnType("int");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
@ -186,6 +224,8 @@ namespace ComputerShopDatabaseImplement.Migrations
b.HasKey("Id");
b.HasIndex("ClientId");
b.ToTable("Orders");
});
@ -197,6 +237,9 @@ namespace ComputerShopDatabaseImplement.Migrations
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int?>("ClientId")
.HasColumnType("int");
b.Property<int>("ComponentId")
.HasColumnType("int");
@ -221,6 +264,8 @@ namespace ComputerShopDatabaseImplement.Migrations
b.HasKey("Id");
b.HasIndex("ClientId");
b.HasIndex("ComponentId");
b.ToTable("Purchases");
@ -234,6 +279,9 @@ namespace ComputerShopDatabaseImplement.Migrations
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int?>("ClientId")
.HasColumnType("int");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
@ -251,6 +299,8 @@ namespace ComputerShopDatabaseImplement.Migrations
b.HasKey("Id");
b.HasIndex("ClientId");
b.ToTable("Supplies");
});
@ -280,6 +330,13 @@ namespace ComputerShopDatabaseImplement.Migrations
b.ToTable("SupplyOrders");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Assembly", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Client", null)
.WithMany("Assemblies")
.HasForeignKey("ClientId");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.AssemblyComponent", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Assembly", "Assembly")
@ -339,13 +396,28 @@ namespace ComputerShopDatabaseImplement.Migrations
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.EquipmentReceiving", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Client", null)
.WithMany("EquipmentReceivings")
.HasForeignKey("ClientId");
b.HasOne("ComputerShopDatabaseImplement.Models.Supply", null)
.WithMany("Receivings")
.HasForeignKey("SupplyId");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Order", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Client", null)
.WithMany("Orders")
.HasForeignKey("ClientId");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Purchase", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Client", null)
.WithMany("Purchases")
.HasForeignKey("ClientId");
b.HasOne("ComputerShopDatabaseImplement.Models.Component", "Component")
.WithMany("Purchases")
.HasForeignKey("ComponentId")
@ -355,6 +427,13 @@ namespace ComputerShopDatabaseImplement.Migrations
b.Navigation("Component");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Supply", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Client", null)
.WithMany("Supplies")
.HasForeignKey("ClientId");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.SupplyOrder", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Order", "Order")
@ -381,6 +460,19 @@ namespace ComputerShopDatabaseImplement.Migrations
b.Navigation("Orders");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Client", b =>
{
b.Navigation("Assemblies");
b.Navigation("EquipmentReceivings");
b.Navigation("Orders");
b.Navigation("Purchases");
b.Navigation("Supplies");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Component", b =>
{
b.Navigation("AssemblyComponents");