From 80385a8faaf323ad92736ef83f2bfa4c10510505 Mon Sep 17 00:00:00 2001 From: kamilia Date: Fri, 21 Jun 2024 23:40:13 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B1=D0=B4=20=D1=88=D0=B0=D0=BB=D0=B8=D0=BB?= =?UTF-8?q?=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AircraftPlantDatabase.cs | 2 +- .../20240326170504_InitialCreate.Designer.cs | 171 ------------------ .../Migrations/20240621094116_NewMigration.cs | 78 -------- ... 20240621193713_InitMigration.Designer.cs} | 8 +- ...ate.cs => 20240621193713_InitMigration.cs} | 61 ++++++- .../AircraftPlantDatabaseModelSnapshot.cs | 4 +- AircraftPlant/AircraftPlantView/Program.cs | 2 +- 7 files changed, 66 insertions(+), 260 deletions(-) delete mode 100644 AircraftPlant/AircraftPlantDatabaseImplement/Migrations/20240326170504_InitialCreate.Designer.cs delete mode 100644 AircraftPlant/AircraftPlantDatabaseImplement/Migrations/20240621094116_NewMigration.cs rename AircraftPlant/AircraftPlantDatabaseImplement/Migrations/{20240621094116_NewMigration.Designer.cs => 20240621193713_InitMigration.Designer.cs} (98%) rename AircraftPlant/AircraftPlantDatabaseImplement/Migrations/{20240326170504_InitialCreate.cs => 20240621193713_InitMigration.cs} (65%) diff --git a/AircraftPlant/AircraftPlantDatabaseImplement/AircraftPlantDatabase.cs b/AircraftPlant/AircraftPlantDatabaseImplement/AircraftPlantDatabase.cs index 2150817..edb7da1 100644 --- a/AircraftPlant/AircraftPlantDatabaseImplement/AircraftPlantDatabase.cs +++ b/AircraftPlant/AircraftPlantDatabaseImplement/AircraftPlantDatabase.cs @@ -15,7 +15,7 @@ namespace AircraftPlantDatabaseImplement { if (optionsBuilder.IsConfigured == false) { - optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-6QDRI0N\SQLEXPRESS;Initial Catalog=AircraftPlantDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); + optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-6QDRI0N\SQLEXPRESS;Initial Catalog=AircraftPlantDatabase10;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); } base.OnConfiguring(optionsBuilder); } diff --git a/AircraftPlant/AircraftPlantDatabaseImplement/Migrations/20240326170504_InitialCreate.Designer.cs b/AircraftPlant/AircraftPlantDatabaseImplement/Migrations/20240326170504_InitialCreate.Designer.cs deleted file mode 100644 index eac223c..0000000 --- a/AircraftPlant/AircraftPlantDatabaseImplement/Migrations/20240326170504_InitialCreate.Designer.cs +++ /dev/null @@ -1,171 +0,0 @@ -// -using System; -using AircraftPlantDatabaseImplement; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace AircraftPlantDatabaseImplement.Migrations -{ - [DbContext(typeof(AircraftPlantDatabase))] - [Migration("20240326170504_InitialCreate")] - partial class InitialCreate - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "7.0.17") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("AircraftPlantDatabaseImplement.Models.Component", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ComponentName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Cost") - .HasColumnType("float"); - - b.HasKey("Id"); - - b.ToTable("Components"); - }); - - modelBuilder.Entity("AircraftPlantDatabaseImplement.Models.Order", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Count") - .HasColumnType("int"); - - b.Property("DateCreate") - .HasColumnType("datetime2"); - - b.Property("DateImplement") - .HasColumnType("datetime2"); - - b.Property("PlaneId") - .HasColumnType("int"); - - b.Property("Status") - .HasColumnType("int"); - - b.Property("Sum") - .HasColumnType("float"); - - b.HasKey("Id"); - - b.HasIndex("PlaneId"); - - b.ToTable("Orders"); - }); - - modelBuilder.Entity("AircraftPlantDatabaseImplement.Models.Plane", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("PlaneName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Price") - .HasColumnType("float"); - - b.HasKey("Id"); - - b.ToTable("Planes"); - }); - - modelBuilder.Entity("AircraftPlantDatabaseImplement.Models.PlaneComponent", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ComponentId") - .HasColumnType("int"); - - b.Property("Count") - .HasColumnType("int"); - - b.Property("PlaneId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("ComponentId"); - - b.HasIndex("PlaneId"); - - b.ToTable("PlaneComponents"); - }); - - modelBuilder.Entity("AircraftPlantDatabaseImplement.Models.Order", b => - { - b.HasOne("AircraftPlantDatabaseImplement.Models.Plane", "Plane") - .WithMany("Orders") - .HasForeignKey("PlaneId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Plane"); - }); - - modelBuilder.Entity("AircraftPlantDatabaseImplement.Models.PlaneComponent", b => - { - b.HasOne("AircraftPlantDatabaseImplement.Models.Component", "Component") - .WithMany("PlaneComponents") - .HasForeignKey("ComponentId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("AircraftPlantDatabaseImplement.Models.Plane", "Plane") - .WithMany("Components") - .HasForeignKey("PlaneId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Component"); - - b.Navigation("Plane"); - }); - - modelBuilder.Entity("AircraftPlantDatabaseImplement.Models.Component", b => - { - b.Navigation("PlaneComponents"); - }); - - modelBuilder.Entity("AircraftPlantDatabaseImplement.Models.Plane", b => - { - b.Navigation("Components"); - - b.Navigation("Orders"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/AircraftPlant/AircraftPlantDatabaseImplement/Migrations/20240621094116_NewMigration.cs b/AircraftPlant/AircraftPlantDatabaseImplement/Migrations/20240621094116_NewMigration.cs deleted file mode 100644 index 2f08a64..0000000 --- a/AircraftPlant/AircraftPlantDatabaseImplement/Migrations/20240621094116_NewMigration.cs +++ /dev/null @@ -1,78 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace AircraftPlantDatabaseImplement.Migrations -{ - /// - public partial class NewMigration : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "Shops", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - ShopName = table.Column(type: "nvarchar(max)", nullable: false), - Address = table.Column(type: "nvarchar(max)", nullable: false), - DateOpening = table.Column(type: "datetime2", nullable: false), - MaxPlanes = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Shops", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "ShopPlanes", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - ShopId = table.Column(type: "int", nullable: false), - PlaneId = table.Column(type: "int", nullable: false), - Count = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_ShopPlanes", x => x.Id); - table.ForeignKey( - name: "FK_ShopPlanes_Planes_PlaneId", - column: x => x.PlaneId, - principalTable: "Planes", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_ShopPlanes_Shops_ShopId", - column: x => x.ShopId, - principalTable: "Shops", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateIndex( - name: "IX_ShopPlanes_PlaneId", - table: "ShopPlanes", - column: "PlaneId"); - - migrationBuilder.CreateIndex( - name: "IX_ShopPlanes_ShopId", - table: "ShopPlanes", - column: "ShopId"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "ShopPlanes"); - - migrationBuilder.DropTable( - name: "Shops"); - } - } -} diff --git a/AircraftPlant/AircraftPlantDatabaseImplement/Migrations/20240621094116_NewMigration.Designer.cs b/AircraftPlant/AircraftPlantDatabaseImplement/Migrations/20240621193713_InitMigration.Designer.cs similarity index 98% rename from AircraftPlant/AircraftPlantDatabaseImplement/Migrations/20240621094116_NewMigration.Designer.cs rename to AircraftPlant/AircraftPlantDatabaseImplement/Migrations/20240621193713_InitMigration.Designer.cs index 1b9363f..cfe7a09 100644 --- a/AircraftPlant/AircraftPlantDatabaseImplement/Migrations/20240621094116_NewMigration.Designer.cs +++ b/AircraftPlant/AircraftPlantDatabaseImplement/Migrations/20240621193713_InitMigration.Designer.cs @@ -12,8 +12,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace AircraftPlantDatabaseImplement.Migrations { [DbContext(typeof(AircraftPlantDatabase))] - [Migration("20240621094116_NewMigration")] - partial class NewMigration + [Migration("20240621193713_InitMigration")] + partial class InitMigration { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -179,13 +179,11 @@ namespace AircraftPlantDatabaseImplement.Migrations modelBuilder.Entity("AircraftPlantDatabaseImplement.Models.Order", b => { - b.HasOne("AircraftPlantDatabaseImplement.Models.Plane", "Plane") + b.HasOne("AircraftPlantDatabaseImplement.Models.Plane", null) .WithMany("Orders") .HasForeignKey("PlaneId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - - b.Navigation("Plane"); }); modelBuilder.Entity("AircraftPlantDatabaseImplement.Models.PlaneComponent", b => diff --git a/AircraftPlant/AircraftPlantDatabaseImplement/Migrations/20240326170504_InitialCreate.cs b/AircraftPlant/AircraftPlantDatabaseImplement/Migrations/20240621193713_InitMigration.cs similarity index 65% rename from AircraftPlant/AircraftPlantDatabaseImplement/Migrations/20240326170504_InitialCreate.cs rename to AircraftPlant/AircraftPlantDatabaseImplement/Migrations/20240621193713_InitMigration.cs index 7d0e945..b920e56 100644 --- a/AircraftPlant/AircraftPlantDatabaseImplement/Migrations/20240326170504_InitialCreate.cs +++ b/AircraftPlant/AircraftPlantDatabaseImplement/Migrations/20240621193713_InitMigration.cs @@ -6,7 +6,7 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace AircraftPlantDatabaseImplement.Migrations { /// - public partial class InitialCreate : Migration + public partial class InitMigration : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) @@ -39,6 +39,22 @@ namespace AircraftPlantDatabaseImplement.Migrations table.PrimaryKey("PK_Planes", x => x.Id); }); + migrationBuilder.CreateTable( + name: "Shops", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ShopName = table.Column(type: "nvarchar(max)", nullable: false), + Address = table.Column(type: "nvarchar(max)", nullable: false), + DateOpening = table.Column(type: "datetime2", nullable: false), + MaxPlanes = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Shops", x => x.Id); + }); + migrationBuilder.CreateTable( name: "Orders", columns: table => new @@ -90,6 +106,33 @@ namespace AircraftPlantDatabaseImplement.Migrations onDelete: ReferentialAction.Cascade); }); + migrationBuilder.CreateTable( + name: "ShopPlanes", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ShopId = table.Column(type: "int", nullable: false), + PlaneId = table.Column(type: "int", nullable: false), + Count = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ShopPlanes", x => x.Id); + table.ForeignKey( + name: "FK_ShopPlanes_Planes_PlaneId", + column: x => x.PlaneId, + principalTable: "Planes", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_ShopPlanes_Shops_ShopId", + column: x => x.ShopId, + principalTable: "Shops", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + migrationBuilder.CreateIndex( name: "IX_Orders_PlaneId", table: "Orders", @@ -104,6 +147,16 @@ namespace AircraftPlantDatabaseImplement.Migrations name: "IX_PlaneComponents_PlaneId", table: "PlaneComponents", column: "PlaneId"); + + migrationBuilder.CreateIndex( + name: "IX_ShopPlanes_PlaneId", + table: "ShopPlanes", + column: "PlaneId"); + + migrationBuilder.CreateIndex( + name: "IX_ShopPlanes_ShopId", + table: "ShopPlanes", + column: "ShopId"); } /// @@ -115,11 +168,17 @@ namespace AircraftPlantDatabaseImplement.Migrations migrationBuilder.DropTable( name: "PlaneComponents"); + migrationBuilder.DropTable( + name: "ShopPlanes"); + migrationBuilder.DropTable( name: "Components"); migrationBuilder.DropTable( name: "Planes"); + + migrationBuilder.DropTable( + name: "Shops"); } } } diff --git a/AircraftPlant/AircraftPlantDatabaseImplement/Migrations/AircraftPlantDatabaseModelSnapshot.cs b/AircraftPlant/AircraftPlantDatabaseImplement/Migrations/AircraftPlantDatabaseModelSnapshot.cs index 535ac0e..dc221f5 100644 --- a/AircraftPlant/AircraftPlantDatabaseImplement/Migrations/AircraftPlantDatabaseModelSnapshot.cs +++ b/AircraftPlant/AircraftPlantDatabaseImplement/Migrations/AircraftPlantDatabaseModelSnapshot.cs @@ -176,13 +176,11 @@ namespace AircraftPlantDatabaseImplement.Migrations modelBuilder.Entity("AircraftPlantDatabaseImplement.Models.Order", b => { - b.HasOne("AircraftPlantDatabaseImplement.Models.Plane", "Plane") + b.HasOne("AircraftPlantDatabaseImplement.Models.Plane", null) .WithMany("Orders") .HasForeignKey("PlaneId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - - b.Navigation("Plane"); }); modelBuilder.Entity("AircraftPlantDatabaseImplement.Models.PlaneComponent", b => diff --git a/AircraftPlant/AircraftPlantView/Program.cs b/AircraftPlant/AircraftPlantView/Program.cs index 216dece..c880187 100644 --- a/AircraftPlant/AircraftPlantView/Program.cs +++ b/AircraftPlant/AircraftPlantView/Program.cs @@ -63,8 +63,8 @@ namespace AircraftPlantView services.AddTransient(); services.AddTransient(); services.AddTransient(); - services.AddTransient(); services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); }