diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230420201528_TwoLabWork07.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230420201528_TwoLabWork07.Designer.cs
new file mode 100644
index 0000000..46a44ca
--- /dev/null
+++ b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230420201528_TwoLabWork07.Designer.cs
@@ -0,0 +1,298 @@
+//
+using System;
+using BlacksmithWorkshopDatabaseImplement;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Metadata;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+#nullable disable
+
+namespace BlacksmithWorkshopDatabaseImplement.Migrations
+{
+ [DbContext(typeof(BlacksmithWorkshopDatabase))]
+ [Migration("20230420201528_TwoLabWork07")]
+ partial class TwoLabWork07
+ {
+ ///
+ 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("BlacksmithWorkshopDatabaseImplement.Models.Client", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("ClientFIO")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Email")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Password")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.HasKey("Id");
+
+ b.ToTable("Clients");
+ });
+
+ modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Implementer", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("ImplementerFIO")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Password")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Qualification")
+ .HasColumnType("int");
+
+ b.Property("WorkExperience")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.ToTable("Implementers");
+ });
+
+ modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("ManufactureName")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Price")
+ .HasColumnType("float");
+
+ b.HasKey("Id");
+
+ b.ToTable("Manufactures");
+ });
+
+ modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ManufactureWorkPiece", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("Count")
+ .HasColumnType("int");
+
+ b.Property("ManufactureId")
+ .HasColumnType("int");
+
+ b.Property("WorkPieceId")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ManufactureId");
+
+ b.HasIndex("WorkPieceId");
+
+ b.ToTable("ManufactureWorkPieces");
+ });
+
+ modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.MessageInfo", b =>
+ {
+ b.Property("MessageId")
+ .HasColumnType("nvarchar(450)");
+
+ b.Property("Body")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("ClientId")
+ .HasColumnType("int");
+
+ b.Property("DateDelivery")
+ .HasColumnType("datetime2");
+
+ b.Property("SenderName")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Subject")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.HasKey("MessageId");
+
+ b.HasIndex("ClientId");
+
+ b.ToTable("Messages");
+ });
+
+ modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Order", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("ClientId")
+ .HasColumnType("int");
+
+ b.Property("Count")
+ .HasColumnType("int");
+
+ b.Property("DateCreate")
+ .HasColumnType("datetime2");
+
+ b.Property("DateImplement")
+ .HasColumnType("datetime2");
+
+ b.Property("ImplementerId")
+ .HasColumnType("int");
+
+ b.Property("ManufactureId")
+ .HasColumnType("int");
+
+ b.Property("Status")
+ .HasColumnType("int");
+
+ b.Property("Sum")
+ .HasColumnType("float");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ClientId");
+
+ b.HasIndex("ImplementerId");
+
+ b.HasIndex("ManufactureId");
+
+ b.ToTable("Orders");
+ });
+
+ modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.WorkPiece", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("Cost")
+ .HasColumnType("float");
+
+ b.Property("WorkPieceName")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.HasKey("Id");
+
+ b.ToTable("WorkPieces");
+ });
+
+ modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.ManufactureWorkPiece", b =>
+ {
+ b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", "Manufacture")
+ .WithMany("WorkPieces")
+ .HasForeignKey("ManufactureId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.WorkPiece", "WorkPiece")
+ .WithMany("ManufactureWorkPieces")
+ .HasForeignKey("WorkPieceId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Manufacture");
+
+ b.Navigation("WorkPiece");
+ });
+
+ modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.MessageInfo", b =>
+ {
+ b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Client", "Client")
+ .WithMany("MessageInfos")
+ .HasForeignKey("ClientId");
+
+ b.Navigation("Client");
+ });
+
+ modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Order", b =>
+ {
+ b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Client", "Client")
+ .WithMany("Orders")
+ .HasForeignKey("ClientId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Implementer", "Implementer")
+ .WithMany("Orders")
+ .HasForeignKey("ImplementerId");
+
+ b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", "Manufacture")
+ .WithMany("Orders")
+ .HasForeignKey("ManufactureId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Client");
+
+ b.Navigation("Implementer");
+
+ b.Navigation("Manufacture");
+ });
+
+ modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Client", b =>
+ {
+ b.Navigation("MessageInfos");
+
+ b.Navigation("Orders");
+ });
+
+ modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Implementer", b =>
+ {
+ b.Navigation("Orders");
+ });
+
+ modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Manufacture", b =>
+ {
+ b.Navigation("Orders");
+
+ b.Navigation("WorkPieces");
+ });
+
+ modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.WorkPiece", b =>
+ {
+ b.Navigation("ManufactureWorkPieces");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230420201528_TwoLabWork07.cs b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230420201528_TwoLabWork07.cs
new file mode 100644
index 0000000..921d516
--- /dev/null
+++ b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/20230420201528_TwoLabWork07.cs
@@ -0,0 +1,59 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace BlacksmithWorkshopDatabaseImplement.Migrations
+{
+ ///
+ public partial class TwoLabWork07 : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.Sql("DELETE FROM [dbo].[Orders]");
+ migrationBuilder.Sql("DELETE FROM [dbo].[Messages]");
+
+ migrationBuilder.AlterColumn(
+ name: "ClientId",
+ table: "Messages",
+ type: "int",
+ nullable: true,
+ oldClrType: typeof(int),
+ oldType: "int");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Messages_ClientId",
+ table: "Messages",
+ column: "ClientId");
+
+ migrationBuilder.AddForeignKey(
+ name: "FK_Messages_Clients_ClientId",
+ table: "Messages",
+ column: "ClientId",
+ principalTable: "Clients",
+ principalColumn: "Id");
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropForeignKey(
+ name: "FK_Messages_Clients_ClientId",
+ table: "Messages");
+
+ migrationBuilder.DropIndex(
+ name: "IX_Messages_ClientId",
+ table: "Messages");
+
+ migrationBuilder.AlterColumn(
+ name: "ClientId",
+ table: "Messages",
+ type: "int",
+ nullable: false,
+ defaultValue: 0,
+ oldClrType: typeof(int),
+ oldType: "int",
+ oldNullable: true);
+ }
+ }
+}
diff --git a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/BlacksmithWorkshopDatabaseModelSnapshot.cs b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/BlacksmithWorkshopDatabaseModelSnapshot.cs
index e084b52..52bb683 100644
--- a/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/BlacksmithWorkshopDatabaseModelSnapshot.cs
+++ b/BlacksmithWorkshop/BlacksmithWorkshopDatabaseImplement/Migrations/BlacksmithWorkshopDatabaseModelSnapshot.cs
@@ -130,7 +130,6 @@ namespace BlacksmithWorkshopDatabaseImplement.Migrations
.HasColumnType("nvarchar(max)");
b.Property("ClientId")
- .IsRequired()
.HasColumnType("int");
b.Property("DateDelivery")
@@ -146,6 +145,8 @@ namespace BlacksmithWorkshopDatabaseImplement.Migrations
b.HasKey("MessageId");
+ b.HasIndex("ClientId");
+
b.ToTable("Messages");
});
@@ -231,6 +232,15 @@ namespace BlacksmithWorkshopDatabaseImplement.Migrations
b.Navigation("WorkPiece");
});
+ modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.MessageInfo", b =>
+ {
+ b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Client", "Client")
+ .WithMany("MessageInfos")
+ .HasForeignKey("ClientId");
+
+ b.Navigation("Client");
+ });
+
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Order", b =>
{
b.HasOne("BlacksmithWorkshopDatabaseImplement.Models.Client", "Client")
@@ -258,6 +268,8 @@ namespace BlacksmithWorkshopDatabaseImplement.Migrations
modelBuilder.Entity("BlacksmithWorkshopDatabaseImplement.Models.Client", b =>
{
+ b.Navigation("MessageInfos");
+
b.Navigation("Orders");
});