From 086247bccee44782d98beba533917eccd8c19612 Mon Sep 17 00:00:00 2001 From: malimova Date: Wed, 1 May 2024 15:23:37 +0400 Subject: [PATCH] =?UTF-8?q?=D0=BF=D0=BE=20=D0=B8=D0=B4=D0=B5=D0=B5=20?= =?UTF-8?q?=D0=BE=D0=B1=D0=BD=D0=BE=D0=B2=D0=B8=D0=BB=D0=B0=20=D0=B4=D0=B0?= =?UTF-8?q?=D1=82=D0=B0=D0=B1=D0=B0=D0=B7=D1=83(=D1=81=D0=BE=D0=B7=D0=B4?= =?UTF-8?q?=D0=B0=D0=BB=D0=B0=20=D0=BD=D0=BE=D0=B2=D1=83=D1=8E),=20=D0=BD?= =?UTF-8?q?=D0=B0=D0=B4=D0=B5=D1=8E=D1=81=D1=8C=20=D0=B2=D1=81=D0=B5=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=B8=D0=BB=D1=8C=D0=BD=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ConfectioneryDatabase.cs | 2 +- ... 20240501112235_InitialCreate.Designer.cs} | 41 ++++++++++++++++++- ...ate.cs => 20240501112235_InitialCreate.cs} | 31 +++++++++++++- .../ConfectioneryDatabaseModelSnapshot.cs | 39 ++++++++++++++++++ 4 files changed, 110 insertions(+), 3 deletions(-) rename Confectionery/ConfectioneryDatabaseImplement/Migrations/{20240328194118_InitialCreate.Designer.cs => 20240501112235_InitialCreate.Designer.cs} (80%) rename Confectionery/ConfectioneryDatabaseImplement/Migrations/{20240328194118_InitialCreate.cs => 20240501112235_InitialCreate.cs} (79%) diff --git a/Confectionery/ConfectioneryDatabaseImplement/ConfectioneryDatabase.cs b/Confectionery/ConfectioneryDatabaseImplement/ConfectioneryDatabase.cs index 9d23119..a4c825a 100644 --- a/Confectionery/ConfectioneryDatabaseImplement/ConfectioneryDatabase.cs +++ b/Confectionery/ConfectioneryDatabaseImplement/ConfectioneryDatabase.cs @@ -15,7 +15,7 @@ namespace ConfectioneryDatabaseImplement { if (optionsBuilder.IsConfigured == false) { - optionsBuilder.UseSqlServer(@"Data Source=localhost\SQLEXPRESS;Initial Catalog=ConfectioneryDatabaseFull;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); + optionsBuilder.UseSqlServer(@"Data Source=localhost\SQLEXPRESS;Initial Catalog=ConfectioneryDatabaseNew;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); } base.OnConfiguring(optionsBuilder); } diff --git a/Confectionery/ConfectioneryDatabaseImplement/Migrations/20240328194118_InitialCreate.Designer.cs b/Confectionery/ConfectioneryDatabaseImplement/Migrations/20240501112235_InitialCreate.Designer.cs similarity index 80% rename from Confectionery/ConfectioneryDatabaseImplement/Migrations/20240328194118_InitialCreate.Designer.cs rename to Confectionery/ConfectioneryDatabaseImplement/Migrations/20240501112235_InitialCreate.Designer.cs index 8dae3f2..cb59e1f 100644 --- a/Confectionery/ConfectioneryDatabaseImplement/Migrations/20240328194118_InitialCreate.Designer.cs +++ b/Confectionery/ConfectioneryDatabaseImplement/Migrations/20240501112235_InitialCreate.Designer.cs @@ -12,7 +12,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace ConfectioneryDatabaseImplement.Migrations { [DbContext(typeof(ConfectioneryDatabase))] - [Migration("20240328194118_InitialCreate")] + [Migration("20240501112235_InitialCreate")] partial class InitialCreate { /// @@ -25,6 +25,31 @@ namespace ConfectioneryDatabaseImplement.Migrations SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + modelBuilder.Entity("ConfectioneryDatabaseImplement.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("ConfectioneryDatabaseImplement.Models.Component", b => { b.Property("Id") @@ -53,6 +78,9 @@ namespace ConfectioneryDatabaseImplement.Migrations SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + b.Property("ClientId") + .HasColumnType("int"); + b.Property("Count") .HasColumnType("int"); @@ -73,6 +101,8 @@ namespace ConfectioneryDatabaseImplement.Migrations b.HasKey("Id"); + b.HasIndex("ClientId"); + b.HasIndex("PastryId"); b.ToTable("Orders"); @@ -126,6 +156,10 @@ namespace ConfectioneryDatabaseImplement.Migrations modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Order", b => { + b.HasOne("ConfectioneryDatabaseImplement.Models.Client", null) + .WithMany("Orders") + .HasForeignKey("ClientId"); + b.HasOne("ConfectioneryDatabaseImplement.Models.Pastry", "Pastry") .WithMany("Orders") .HasForeignKey("PastryId") @@ -154,6 +188,11 @@ namespace ConfectioneryDatabaseImplement.Migrations b.Navigation("Pastry"); }); + modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Client", b => + { + b.Navigation("Orders"); + }); + modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Component", b => { b.Navigation("PastryComponents"); diff --git a/Confectionery/ConfectioneryDatabaseImplement/Migrations/20240328194118_InitialCreate.cs b/Confectionery/ConfectioneryDatabaseImplement/Migrations/20240501112235_InitialCreate.cs similarity index 79% rename from Confectionery/ConfectioneryDatabaseImplement/Migrations/20240328194118_InitialCreate.cs rename to Confectionery/ConfectioneryDatabaseImplement/Migrations/20240501112235_InitialCreate.cs index b3075ba..7655913 100644 --- a/Confectionery/ConfectioneryDatabaseImplement/Migrations/20240328194118_InitialCreate.cs +++ b/Confectionery/ConfectioneryDatabaseImplement/Migrations/20240501112235_InitialCreate.cs @@ -11,6 +11,21 @@ namespace ConfectioneryDatabaseImplement.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 @@ -45,16 +60,22 @@ namespace ConfectioneryDatabaseImplement.Migrations { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), + PastryId = 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), DateCreate = table.Column(type: "datetime2", nullable: false), DateImplement = table.Column(type: "datetime2", nullable: true), - PastryId = table.Column(type: "int", nullable: false) + ClientId = table.Column(type: "int", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Orders", x => x.Id); + table.ForeignKey( + name: "FK_Orders_Clients_ClientId", + column: x => x.ClientId, + principalTable: "Clients", + principalColumn: "Id"); table.ForeignKey( name: "FK_Orders_Pastrys_PastryId", column: x => x.PastryId, @@ -90,6 +111,11 @@ namespace ConfectioneryDatabaseImplement.Migrations onDelete: ReferentialAction.Cascade); }); + migrationBuilder.CreateIndex( + name: "IX_Orders_ClientId", + table: "Orders", + column: "ClientId"); + migrationBuilder.CreateIndex( name: "IX_Orders_PastryId", table: "Orders", @@ -115,6 +141,9 @@ namespace ConfectioneryDatabaseImplement.Migrations migrationBuilder.DropTable( name: "PastryComponents"); + migrationBuilder.DropTable( + name: "Clients"); + migrationBuilder.DropTable( name: "Components"); diff --git a/Confectionery/ConfectioneryDatabaseImplement/Migrations/ConfectioneryDatabaseModelSnapshot.cs b/Confectionery/ConfectioneryDatabaseImplement/Migrations/ConfectioneryDatabaseModelSnapshot.cs index 6909147..912d903 100644 --- a/Confectionery/ConfectioneryDatabaseImplement/Migrations/ConfectioneryDatabaseModelSnapshot.cs +++ b/Confectionery/ConfectioneryDatabaseImplement/Migrations/ConfectioneryDatabaseModelSnapshot.cs @@ -22,6 +22,31 @@ namespace ConfectioneryDatabaseImplement.Migrations SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + modelBuilder.Entity("ConfectioneryDatabaseImplement.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("ConfectioneryDatabaseImplement.Models.Component", b => { b.Property("Id") @@ -50,6 +75,9 @@ namespace ConfectioneryDatabaseImplement.Migrations SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + b.Property("ClientId") + .HasColumnType("int"); + b.Property("Count") .HasColumnType("int"); @@ -70,6 +98,8 @@ namespace ConfectioneryDatabaseImplement.Migrations b.HasKey("Id"); + b.HasIndex("ClientId"); + b.HasIndex("PastryId"); b.ToTable("Orders"); @@ -123,6 +153,10 @@ namespace ConfectioneryDatabaseImplement.Migrations modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Order", b => { + b.HasOne("ConfectioneryDatabaseImplement.Models.Client", null) + .WithMany("Orders") + .HasForeignKey("ClientId"); + b.HasOne("ConfectioneryDatabaseImplement.Models.Pastry", "Pastry") .WithMany("Orders") .HasForeignKey("PastryId") @@ -151,6 +185,11 @@ namespace ConfectioneryDatabaseImplement.Migrations b.Navigation("Pastry"); }); + modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Client", b => + { + b.Navigation("Orders"); + }); + modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Component", b => { b.Navigation("PastryComponents");