From c28d6e23b38fe4ba616c0e503404d2d40ddfb3fb Mon Sep 17 00:00:00 2001 From: Kirill <117719052+KirillFirsof@users.noreply.github.com> Date: Wed, 1 May 2024 23:15:21 +0400 Subject: [PATCH] =?UTF-8?q?=D0=94=D1=80=D0=BE=D0=BF=D0=BD=D1=83=D0=BB=20?= =?UTF-8?q?=D0=B8=20=D0=BF=D0=B5=D1=80=D0=B5=D1=81=D0=BE=D0=B7=D0=B4=D0=B0?= =?UTF-8?q?=D0=BB=20=D0=BC=D0=B8=D0=B3=D1=80=D0=B0=D1=86=D0=B8=D1=8E=20?= =?UTF-8?q?=D0=B8=20=D0=BE=D0=B1=D0=BD=D0=BE=D0=B2=D0=B8=D0=BB=20=D0=B1?= =?UTF-8?q?=D0=B0=D0=B7=D1=83=20=D0=B4=D0=B0=D0=BD=D0=BD=D1=8B=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... 20240501191433_InitialCreate.Designer.cs} | 68 ++++++++++++++++++- ...ate.cs => 20240501191433_InitialCreate.cs} | 57 +++++++++++++++- .../Migrations/SchoolDatabaseModelSnapshot.cs | 66 ++++++++++++++++++ 3 files changed, 189 insertions(+), 2 deletions(-) rename School/SchoolDatabaseImplement/Migrations/{20240430191557_InitialCreate.Designer.cs => 20240501191433_InitialCreate.Designer.cs} (76%) rename School/SchoolDatabaseImplement/Migrations/{20240430191557_InitialCreate.cs => 20240501191433_InitialCreate.cs} (73%) diff --git a/School/SchoolDatabaseImplement/Migrations/20240430191557_InitialCreate.Designer.cs b/School/SchoolDatabaseImplement/Migrations/20240501191433_InitialCreate.Designer.cs similarity index 76% rename from School/SchoolDatabaseImplement/Migrations/20240430191557_InitialCreate.Designer.cs rename to School/SchoolDatabaseImplement/Migrations/20240501191433_InitialCreate.Designer.cs index edbcfe4..c0a58e5 100644 --- a/School/SchoolDatabaseImplement/Migrations/20240430191557_InitialCreate.Designer.cs +++ b/School/SchoolDatabaseImplement/Migrations/20240501191433_InitialCreate.Designer.cs @@ -12,7 +12,7 @@ using SchoolDatabaseImplement; namespace SchoolDatabaseImplement.Migrations { [DbContext(typeof(SchoolDatabase))] - [Migration("20240430191557_InitialCreate")] + [Migration("20240501191433_InitialCreate")] partial class InitialCreate { /// @@ -102,6 +102,29 @@ namespace SchoolDatabaseImplement.Migrations b.ToTable("InterestLessons"); }); + modelBuilder.Entity("SchoolDatabaseImplement.Models.InterestMaterial", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("InterestId") + .HasColumnType("int"); + + b.Property("MaterialId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("InterestId"); + + b.HasIndex("MaterialId"); + + b.ToTable("InterestMaterial"); + }); + modelBuilder.Entity("SchoolDatabaseImplement.Models.Lesson", b => { b.Property("Id") @@ -126,6 +149,23 @@ namespace SchoolDatabaseImplement.Migrations b.ToTable("Lessons"); }); + modelBuilder.Entity("SchoolDatabaseImplement.Models.Material", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Material"); + }); + modelBuilder.Entity("SchoolDatabaseImplement.Models.User", b => { b.Property("Id") @@ -188,6 +228,25 @@ namespace SchoolDatabaseImplement.Migrations b.Navigation("Lesson"); }); + modelBuilder.Entity("SchoolDatabaseImplement.Models.InterestMaterial", b => + { + b.HasOne("SchoolDatabaseImplement.Models.Interest", "Interest") + .WithMany("Materials") + .HasForeignKey("InterestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("SchoolDatabaseImplement.Models.Material", "Material") + .WithMany("InterestMaterials") + .HasForeignKey("MaterialId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Interest"); + + b.Navigation("Material"); + }); + modelBuilder.Entity("SchoolDatabaseImplement.Models.Lesson", b => { b.HasOne("SchoolDatabaseImplement.Models.User", "User") @@ -202,6 +261,8 @@ namespace SchoolDatabaseImplement.Migrations modelBuilder.Entity("SchoolDatabaseImplement.Models.Interest", b => { b.Navigation("Lessons"); + + b.Navigation("Materials"); }); modelBuilder.Entity("SchoolDatabaseImplement.Models.Lesson", b => @@ -211,6 +272,11 @@ namespace SchoolDatabaseImplement.Migrations b.Navigation("InterestLessons"); }); + modelBuilder.Entity("SchoolDatabaseImplement.Models.Material", b => + { + b.Navigation("InterestMaterials"); + }); + modelBuilder.Entity("SchoolDatabaseImplement.Models.User", b => { b.Navigation("Lessons"); diff --git a/School/SchoolDatabaseImplement/Migrations/20240430191557_InitialCreate.cs b/School/SchoolDatabaseImplement/Migrations/20240501191433_InitialCreate.cs similarity index 73% rename from School/SchoolDatabaseImplement/Migrations/20240430191557_InitialCreate.cs rename to School/SchoolDatabaseImplement/Migrations/20240501191433_InitialCreate.cs index 8c634fa..54b121a 100644 --- a/School/SchoolDatabaseImplement/Migrations/20240430191557_InitialCreate.cs +++ b/School/SchoolDatabaseImplement/Migrations/20240501191433_InitialCreate.cs @@ -26,6 +26,19 @@ namespace SchoolDatabaseImplement.Migrations table.PrimaryKey("PK_Interests", x => x.Id); }); + migrationBuilder.CreateTable( + name: "Material", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Name = table.Column(type: "nvarchar(max)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Material", x => x.Id); + }); + migrationBuilder.CreateTable( name: "Users", columns: table => new @@ -43,6 +56,32 @@ namespace SchoolDatabaseImplement.Migrations table.PrimaryKey("PK_Users", x => x.Id); }); + migrationBuilder.CreateTable( + name: "InterestMaterial", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + InterestId = table.Column(type: "int", nullable: false), + MaterialId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_InterestMaterial", x => x.Id); + table.ForeignKey( + name: "FK_InterestMaterial_Interests_InterestId", + column: x => x.InterestId, + principalTable: "Interests", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_InterestMaterial_Material_MaterialId", + column: x => x.MaterialId, + principalTable: "Material", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + migrationBuilder.CreateTable( name: "Lessons", columns: table => new @@ -127,6 +166,16 @@ namespace SchoolDatabaseImplement.Migrations table: "InterestLessons", column: "LessonId"); + migrationBuilder.CreateIndex( + name: "IX_InterestMaterial_InterestId", + table: "InterestMaterial", + column: "InterestId"); + + migrationBuilder.CreateIndex( + name: "IX_InterestMaterial_MaterialId", + table: "InterestMaterial", + column: "MaterialId"); + migrationBuilder.CreateIndex( name: "IX_Lessons_UserId", table: "Lessons", @@ -143,11 +192,17 @@ namespace SchoolDatabaseImplement.Migrations name: "InterestLessons"); migrationBuilder.DropTable( - name: "Interests"); + name: "InterestMaterial"); migrationBuilder.DropTable( name: "Lessons"); + migrationBuilder.DropTable( + name: "Interests"); + + migrationBuilder.DropTable( + name: "Material"); + migrationBuilder.DropTable( name: "Users"); } diff --git a/School/SchoolDatabaseImplement/Migrations/SchoolDatabaseModelSnapshot.cs b/School/SchoolDatabaseImplement/Migrations/SchoolDatabaseModelSnapshot.cs index d8cc9cc..6dd339e 100644 --- a/School/SchoolDatabaseImplement/Migrations/SchoolDatabaseModelSnapshot.cs +++ b/School/SchoolDatabaseImplement/Migrations/SchoolDatabaseModelSnapshot.cs @@ -99,6 +99,29 @@ namespace SchoolDatabaseImplement.Migrations b.ToTable("InterestLessons"); }); + modelBuilder.Entity("SchoolDatabaseImplement.Models.InterestMaterial", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("InterestId") + .HasColumnType("int"); + + b.Property("MaterialId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("InterestId"); + + b.HasIndex("MaterialId"); + + b.ToTable("InterestMaterial"); + }); + modelBuilder.Entity("SchoolDatabaseImplement.Models.Lesson", b => { b.Property("Id") @@ -123,6 +146,23 @@ namespace SchoolDatabaseImplement.Migrations b.ToTable("Lessons"); }); + modelBuilder.Entity("SchoolDatabaseImplement.Models.Material", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Material"); + }); + modelBuilder.Entity("SchoolDatabaseImplement.Models.User", b => { b.Property("Id") @@ -185,6 +225,25 @@ namespace SchoolDatabaseImplement.Migrations b.Navigation("Lesson"); }); + modelBuilder.Entity("SchoolDatabaseImplement.Models.InterestMaterial", b => + { + b.HasOne("SchoolDatabaseImplement.Models.Interest", "Interest") + .WithMany("Materials") + .HasForeignKey("InterestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("SchoolDatabaseImplement.Models.Material", "Material") + .WithMany("InterestMaterials") + .HasForeignKey("MaterialId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Interest"); + + b.Navigation("Material"); + }); + modelBuilder.Entity("SchoolDatabaseImplement.Models.Lesson", b => { b.HasOne("SchoolDatabaseImplement.Models.User", "User") @@ -199,6 +258,8 @@ namespace SchoolDatabaseImplement.Migrations modelBuilder.Entity("SchoolDatabaseImplement.Models.Interest", b => { b.Navigation("Lessons"); + + b.Navigation("Materials"); }); modelBuilder.Entity("SchoolDatabaseImplement.Models.Lesson", b => @@ -208,6 +269,11 @@ namespace SchoolDatabaseImplement.Migrations b.Navigation("InterestLessons"); }); + modelBuilder.Entity("SchoolDatabaseImplement.Models.Material", b => + { + b.Navigation("InterestMaterials"); + }); + modelBuilder.Entity("SchoolDatabaseImplement.Models.User", b => { b.Navigation("Lessons");