diff --git a/BeautySalonView/BeautySalonDatabaseImplement/Migrations/20240501133019_initial.Designer.cs b/BeautySalonView/BeautySalonDatabaseImplement/Migrations/20240501140440_initial.Designer.cs similarity index 98% rename from BeautySalonView/BeautySalonDatabaseImplement/Migrations/20240501133019_initial.Designer.cs rename to BeautySalonView/BeautySalonDatabaseImplement/Migrations/20240501140440_initial.Designer.cs index c37ae3c..eedb788 100644 --- a/BeautySalonView/BeautySalonDatabaseImplement/Migrations/20240501133019_initial.Designer.cs +++ b/BeautySalonView/BeautySalonDatabaseImplement/Migrations/20240501140440_initial.Designer.cs @@ -12,7 +12,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace BeautySalonDatabaseImplement.Migrations { [DbContext(typeof(BeautySalonDatabase))] - [Migration("20240501133019_initial")] + [Migration("20240501140440_initial")] partial class initial { /// @@ -181,17 +181,12 @@ namespace BeautySalonDatabaseImplement.Migrations b.Property("OrderId") .HasColumnType("int"); - b.Property("ProcedureId") - .HasColumnType("int"); - b.HasKey("Id"); b.HasIndex("CosmeticId"); b.HasIndex("OrderId"); - b.HasIndex("ProcedureId"); - b.ToTable("OrderCosmetics"); }); @@ -487,10 +482,6 @@ namespace BeautySalonDatabaseImplement.Migrations .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("BeautySalonDatabaseImplement.Models.Procedure", null) - .WithMany("Orders") - .HasForeignKey("ProcedureId"); - b.Navigation("Cosmetic"); b.Navigation("Order"); @@ -505,7 +496,7 @@ namespace BeautySalonDatabaseImplement.Migrations .IsRequired(); b.HasOne("BeautySalonDatabaseImplement.Models.Procedure", "Procedure") - .WithMany() + .WithMany("Orders") .HasForeignKey("ProcedureId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); diff --git a/BeautySalonView/BeautySalonDatabaseImplement/Migrations/20240501133019_initial.cs b/BeautySalonView/BeautySalonDatabaseImplement/Migrations/20240501140440_initial.cs similarity index 97% rename from BeautySalonView/BeautySalonDatabaseImplement/Migrations/20240501133019_initial.cs rename to BeautySalonView/BeautySalonDatabaseImplement/Migrations/20240501140440_initial.cs index 441c717..32f59b7 100644 --- a/BeautySalonView/BeautySalonDatabaseImplement/Migrations/20240501133019_initial.cs +++ b/BeautySalonView/BeautySalonDatabaseImplement/Migrations/20240501140440_initial.cs @@ -86,7 +86,7 @@ namespace BeautySalonDatabaseImplement.Migrations column: x => x.ClientId, principalTable: "Clients", principalColumn: "Id", - onDelete: ReferentialAction.Cascade); + onDelete: ReferentialAction.NoAction); }); migrationBuilder.CreateTable( @@ -183,7 +183,7 @@ namespace BeautySalonDatabaseImplement.Migrations column: x => x.ProcedureId, principalTable: "Procedures", principalColumn: "Id", - onDelete: ReferentialAction.NoAction); + onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( @@ -296,8 +296,7 @@ namespace BeautySalonDatabaseImplement.Migrations Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), OrderId = table.Column(type: "int", nullable: false), - CosmeticId = table.Column(type: "int", nullable: false), - ProcedureId = table.Column(type: "int", nullable: true) + CosmeticId = table.Column(type: "int", nullable: false) }, constraints: table => { @@ -314,11 +313,6 @@ namespace BeautySalonDatabaseImplement.Migrations principalTable: "Orders", principalColumn: "Id", onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_OrderCosmetics_Procedures_ProcedureId", - column: x => x.ProcedureId, - principalTable: "Procedures", - principalColumn: "Id"); }); migrationBuilder.CreateTable( @@ -388,11 +382,6 @@ namespace BeautySalonDatabaseImplement.Migrations table: "OrderCosmetics", column: "OrderId"); - migrationBuilder.CreateIndex( - name: "IX_OrderCosmetics_ProcedureId", - table: "OrderCosmetics", - column: "ProcedureId"); - migrationBuilder.CreateIndex( name: "IX_OrderProcedures_OrderId", table: "OrderProcedures", diff --git a/BeautySalonView/BeautySalonDatabaseImplement/Migrations/BeautySalonDatabaseModelSnapshot.cs b/BeautySalonView/BeautySalonDatabaseImplement/Migrations/BeautySalonDatabaseModelSnapshot.cs index 8e71c65..2399607 100644 --- a/BeautySalonView/BeautySalonDatabaseImplement/Migrations/BeautySalonDatabaseModelSnapshot.cs +++ b/BeautySalonView/BeautySalonDatabaseImplement/Migrations/BeautySalonDatabaseModelSnapshot.cs @@ -178,17 +178,12 @@ namespace BeautySalonDatabaseImplement.Migrations b.Property("OrderId") .HasColumnType("int"); - b.Property("ProcedureId") - .HasColumnType("int"); - b.HasKey("Id"); b.HasIndex("CosmeticId"); b.HasIndex("OrderId"); - b.HasIndex("ProcedureId"); - b.ToTable("OrderCosmetics"); }); @@ -484,10 +479,6 @@ namespace BeautySalonDatabaseImplement.Migrations .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("BeautySalonDatabaseImplement.Models.Procedure", null) - .WithMany("Orders") - .HasForeignKey("ProcedureId"); - b.Navigation("Cosmetic"); b.Navigation("Order"); @@ -502,7 +493,7 @@ namespace BeautySalonDatabaseImplement.Migrations .IsRequired(); b.HasOne("BeautySalonDatabaseImplement.Models.Procedure", "Procedure") - .WithMany() + .WithMany("Orders") .HasForeignKey("ProcedureId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); diff --git a/BeautySalonView/BeautySalonDatabaseImplement/Models/Procedure.cs b/BeautySalonView/BeautySalonDatabaseImplement/Models/Procedure.cs index 2157f5a..e3b5edc 100644 --- a/BeautySalonView/BeautySalonDatabaseImplement/Models/Procedure.cs +++ b/BeautySalonView/BeautySalonDatabaseImplement/Models/Procedure.cs @@ -63,7 +63,7 @@ namespace BeautySalonDatabaseImplement.Models // связь процедур и заказов многие - ко - многим [ForeignKey("ProcedureId")] - public virtual List Orders { get; set; } = new(); + public virtual List Orders { get; set; } = new(); // связь процедур и заказов многие - ко - многим [ForeignKey("ProcedureId")]