diff --git a/SoftwareInstallation/SoftWareInstallationDatabaseImplement/Migrations/20230403200159_InitialCreate.Designer.cs b/SoftwareInstallation/SoftWareInstallationDatabaseImplement/Migrations/20230425001835_InitialCreate.Designer.cs similarity index 85% rename from SoftwareInstallation/SoftWareInstallationDatabaseImplement/Migrations/20230403200159_InitialCreate.Designer.cs rename to SoftwareInstallation/SoftWareInstallationDatabaseImplement/Migrations/20230425001835_InitialCreate.Designer.cs index 655ad16..01d3403 100644 --- a/SoftwareInstallation/SoftWareInstallationDatabaseImplement/Migrations/20230403200159_InitialCreate.Designer.cs +++ b/SoftwareInstallation/SoftWareInstallationDatabaseImplement/Migrations/20230425001835_InitialCreate.Designer.cs @@ -12,7 +12,7 @@ using SoftwareInstallationDatabaseImplement; namespace SoftWareInstallationDatabaseImplement.Migrations { [DbContext(typeof(SoftwareInstallationDatabase))] - [Migration("20230403200159_InitialCreate")] + [Migration("20230425001835_InitialCreate")] partial class InitialCreate { /// @@ -25,6 +25,31 @@ namespace SoftWareInstallationDatabaseImplement.Migrations SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + modelBuilder.Entity("SoftwareInstallationDatabaseImplement.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("SoftwareInstallationDatabaseImplement.Models.Component", b => { b.Property("Id") @@ -53,6 +78,9 @@ namespace SoftWareInstallationDatabaseImplement.Migrations SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + b.Property("ClientId") + .HasColumnType("int"); + b.Property("Count") .HasColumnType("int"); @@ -73,6 +101,8 @@ namespace SoftWareInstallationDatabaseImplement.Migrations b.HasKey("Id"); + b.HasIndex("ClientId"); + b.HasIndex("PackageId"); b.ToTable("Orders"); @@ -184,12 +214,20 @@ namespace SoftWareInstallationDatabaseImplement.Migrations modelBuilder.Entity("SoftwareInstallationDatabaseImplement.Models.Order", b => { + b.HasOne("SoftwareInstallationDatabaseImplement.Models.Client", "Client") + .WithMany("Orders") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + b.HasOne("SoftwareInstallationDatabaseImplement.Models.Package", "Package") .WithMany("Orders") .HasForeignKey("PackageId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + b.Navigation("Client"); + b.Navigation("Package"); }); @@ -238,6 +276,11 @@ namespace SoftWareInstallationDatabaseImplement.Migrations b.Navigation("Shop"); }); + modelBuilder.Entity("SoftwareInstallationDatabaseImplement.Models.Client", b => + { + b.Navigation("Orders"); + }); + modelBuilder.Entity("SoftwareInstallationDatabaseImplement.Models.Component", b => { b.Navigation("PackageComponents"); diff --git a/SoftwareInstallation/SoftWareInstallationDatabaseImplement/Migrations/20230403200159_InitialCreate.cs b/SoftwareInstallation/SoftWareInstallationDatabaseImplement/Migrations/20230425001835_InitialCreate.cs similarity index 86% rename from SoftwareInstallation/SoftWareInstallationDatabaseImplement/Migrations/20230403200159_InitialCreate.cs rename to SoftwareInstallation/SoftWareInstallationDatabaseImplement/Migrations/20230425001835_InitialCreate.cs index aebae84..443c8a5 100644 --- a/SoftwareInstallation/SoftWareInstallationDatabaseImplement/Migrations/20230403200159_InitialCreate.cs +++ b/SoftwareInstallation/SoftWareInstallationDatabaseImplement/Migrations/20230425001835_InitialCreate.cs @@ -11,6 +11,21 @@ namespace SoftWareInstallationDatabaseImplement.Migrations /// protected override void Up(MigrationBuilder migrationBuilder) { + migrationBuilder.CreateTable( + name: "Clients", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ClientFIO = table.Column(type: "nvarchar(max)", nullable: false), + Email = table.Column(type: "nvarchar(max)", nullable: false), + Password = table.Column(type: "nvarchar(max)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Clients", x => x.Id); + }); + migrationBuilder.CreateTable( name: "Components", columns: table => new @@ -46,6 +61,7 @@ namespace SoftWareInstallationDatabaseImplement.Migrations Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), PackageId = table.Column(type: "int", nullable: false), + ClientId = table.Column(type: "int", nullable: false), Count = table.Column(type: "int", nullable: false), Sum = table.Column(type: "float", nullable: false), Status = table.Column(type: "int", nullable: false), @@ -55,6 +71,12 @@ namespace SoftWareInstallationDatabaseImplement.Migrations constraints: table => { table.PrimaryKey("PK_Orders", x => x.Id); + table.ForeignKey( + name: "FK_Orders_Clients_ClientId", + column: x => x.ClientId, + principalTable: "Clients", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_Orders_Packages_PackageId", column: x => x.PackageId, @@ -139,6 +161,11 @@ namespace SoftWareInstallationDatabaseImplement.Migrations onDelete: ReferentialAction.Cascade); }); + migrationBuilder.CreateIndex( + name: "IX_Orders_ClientId", + table: "Orders", + column: "ClientId"); + migrationBuilder.CreateIndex( name: "IX_Orders_PackageId", table: "Orders", @@ -182,6 +209,9 @@ namespace SoftWareInstallationDatabaseImplement.Migrations migrationBuilder.DropTable( name: "ShopPackages"); + migrationBuilder.DropTable( + name: "Clients"); + migrationBuilder.DropTable( name: "Components"); diff --git a/SoftwareInstallation/SoftWareInstallationDatabaseImplement/Migrations/SoftwareInstallationDatabaseModelSnapshot.cs b/SoftwareInstallation/SoftWareInstallationDatabaseImplement/Migrations/SoftwareInstallationDatabaseModelSnapshot.cs index 1c1f234..88c39d9 100644 --- a/SoftwareInstallation/SoftWareInstallationDatabaseImplement/Migrations/SoftwareInstallationDatabaseModelSnapshot.cs +++ b/SoftwareInstallation/SoftWareInstallationDatabaseImplement/Migrations/SoftwareInstallationDatabaseModelSnapshot.cs @@ -22,6 +22,31 @@ namespace SoftWareInstallationDatabaseImplement.Migrations SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + modelBuilder.Entity("SoftwareInstallationDatabaseImplement.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("SoftwareInstallationDatabaseImplement.Models.Component", b => { b.Property("Id") @@ -50,6 +75,9 @@ namespace SoftWareInstallationDatabaseImplement.Migrations SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + b.Property("ClientId") + .HasColumnType("int"); + b.Property("Count") .HasColumnType("int"); @@ -70,6 +98,8 @@ namespace SoftWareInstallationDatabaseImplement.Migrations b.HasKey("Id"); + b.HasIndex("ClientId"); + b.HasIndex("PackageId"); b.ToTable("Orders"); @@ -181,12 +211,20 @@ namespace SoftWareInstallationDatabaseImplement.Migrations modelBuilder.Entity("SoftwareInstallationDatabaseImplement.Models.Order", b => { + b.HasOne("SoftwareInstallationDatabaseImplement.Models.Client", "Client") + .WithMany("Orders") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + b.HasOne("SoftwareInstallationDatabaseImplement.Models.Package", "Package") .WithMany("Orders") .HasForeignKey("PackageId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + b.Navigation("Client"); + b.Navigation("Package"); }); @@ -235,6 +273,11 @@ namespace SoftWareInstallationDatabaseImplement.Migrations b.Navigation("Shop"); }); + modelBuilder.Entity("SoftwareInstallationDatabaseImplement.Models.Client", b => + { + b.Navigation("Orders"); + }); + modelBuilder.Entity("SoftwareInstallationDatabaseImplement.Models.Component", b => { b.Navigation("PackageComponents"); diff --git a/SoftwareInstallation/SoftWareInstallationDatabaseImplement/SoftWareInstallationDatabaseImplement.csproj b/SoftwareInstallation/SoftWareInstallationDatabaseImplement/SoftWareInstallationDatabaseImplement.csproj index 10f4c47..6afd4a5 100644 --- a/SoftwareInstallation/SoftWareInstallationDatabaseImplement/SoftWareInstallationDatabaseImplement.csproj +++ b/SoftwareInstallation/SoftWareInstallationDatabaseImplement/SoftWareInstallationDatabaseImplement.csproj @@ -20,4 +20,8 @@ + + + +