From 8292e1a4ae26236f33786c343ed18c889fe2b39e Mon Sep 17 00:00:00 2001
From: Kirill <117719052+KirillFirsof@users.noreply.github.com>
Date: Thu, 2 May 2024 19:50:30 +0400
Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=BF=D1=8F=D1=82=D1=8C=20=D0=B4=D1=80?=
=?UTF-8?q?=D0=BE=D0=BF=D0=BD=D1=83=D0=BB=D0=BC=D0=B8=D0=B3=D1=80=D0=B0?=
=?UTF-8?q?=D1=86=D0=B8=D1=8E=20=D0=B8=20=D1=81=D0=B4=D0=B5=D0=BB=D0=B0?=
=?UTF-8?q?=D0=BB=20=D0=B7=D0=B0=D0=BD=D0=BE=D0=B2=D0=BE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
... 20240502154944_InitialCreate.Designer.cs} | 70 +++++++++++++++-
...ate.cs => 20240502154944_InitialCreate.cs} | 81 ++++++++++++++++---
.../Migrations/SchoolDatabaseModelSnapshot.cs | 68 +++++++++++++++-
.../SchoolDatabaseImplement/SchoolDatabase.cs | 5 ++
4 files changed, 206 insertions(+), 18 deletions(-)
rename School/SchoolDatabaseImplement/Migrations/{20240501191433_InitialCreate.Designer.cs => 20240502154944_InitialCreate.Designer.cs} (80%)
rename School/SchoolDatabaseImplement/Migrations/{20240501191433_InitialCreate.cs => 20240502154944_InitialCreate.cs} (73%)
diff --git a/School/SchoolDatabaseImplement/Migrations/20240501191433_InitialCreate.Designer.cs b/School/SchoolDatabaseImplement/Migrations/20240502154944_InitialCreate.Designer.cs
similarity index 80%
rename from School/SchoolDatabaseImplement/Migrations/20240501191433_InitialCreate.Designer.cs
rename to School/SchoolDatabaseImplement/Migrations/20240502154944_InitialCreate.Designer.cs
index c0a58e5..70870b2 100644
--- a/School/SchoolDatabaseImplement/Migrations/20240501191433_InitialCreate.Designer.cs
+++ b/School/SchoolDatabaseImplement/Migrations/20240502154944_InitialCreate.Designer.cs
@@ -12,7 +12,7 @@ using SchoolDatabaseImplement;
namespace SchoolDatabaseImplement.Migrations
{
[DbContext(typeof(SchoolDatabase))]
- [Migration("20240501191433_InitialCreate")]
+ [Migration("20240502154944_InitialCreate")]
partial class InitialCreate
{
///
@@ -54,6 +54,46 @@ namespace SchoolDatabaseImplement.Migrations
b.ToTable("Achievements");
});
+ modelBuilder.Entity("SchoolDatabaseImplement.Models.Club", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.HasKey("Id");
+
+ b.ToTable("Clubs");
+ });
+
+ modelBuilder.Entity("SchoolDatabaseImplement.Models.ClubLesson", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("ClubId")
+ .HasColumnType("int");
+
+ b.Property("LessonId")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ClubId");
+
+ b.HasIndex("LessonId");
+
+ b.ToTable("ClubLessons");
+ });
+
modelBuilder.Entity("SchoolDatabaseImplement.Models.Interest", b =>
{
b.Property("Id")
@@ -122,7 +162,7 @@ namespace SchoolDatabaseImplement.Migrations
b.HasIndex("MaterialId");
- b.ToTable("InterestMaterial");
+ b.ToTable("InterestMaterials");
});
modelBuilder.Entity("SchoolDatabaseImplement.Models.Lesson", b =>
@@ -163,7 +203,7 @@ namespace SchoolDatabaseImplement.Migrations
b.HasKey("Id");
- b.ToTable("Material");
+ b.ToTable("Materials");
});
modelBuilder.Entity("SchoolDatabaseImplement.Models.User", b =>
@@ -209,6 +249,25 @@ namespace SchoolDatabaseImplement.Migrations
b.Navigation("Lesson");
});
+ modelBuilder.Entity("SchoolDatabaseImplement.Models.ClubLesson", b =>
+ {
+ b.HasOne("SchoolDatabaseImplement.Models.Club", "Club")
+ .WithMany("Lessons")
+ .HasForeignKey("ClubId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("SchoolDatabaseImplement.Models.Lesson", "Lesson")
+ .WithMany()
+ .HasForeignKey("LessonId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Club");
+
+ b.Navigation("Lesson");
+ });
+
modelBuilder.Entity("SchoolDatabaseImplement.Models.InterestLesson", b =>
{
b.HasOne("SchoolDatabaseImplement.Models.Interest", "Interest")
@@ -258,6 +317,11 @@ namespace SchoolDatabaseImplement.Migrations
b.Navigation("User");
});
+ modelBuilder.Entity("SchoolDatabaseImplement.Models.Club", b =>
+ {
+ b.Navigation("Lessons");
+ });
+
modelBuilder.Entity("SchoolDatabaseImplement.Models.Interest", b =>
{
b.Navigation("Lessons");
diff --git a/School/SchoolDatabaseImplement/Migrations/20240501191433_InitialCreate.cs b/School/SchoolDatabaseImplement/Migrations/20240502154944_InitialCreate.cs
similarity index 73%
rename from School/SchoolDatabaseImplement/Migrations/20240501191433_InitialCreate.cs
rename to School/SchoolDatabaseImplement/Migrations/20240502154944_InitialCreate.cs
index 54b121a..6821471 100644
--- a/School/SchoolDatabaseImplement/Migrations/20240501191433_InitialCreate.cs
+++ b/School/SchoolDatabaseImplement/Migrations/20240502154944_InitialCreate.cs
@@ -11,6 +11,19 @@ namespace SchoolDatabaseImplement.Migrations
///
protected override void Up(MigrationBuilder migrationBuilder)
{
+ migrationBuilder.CreateTable(
+ name: "Clubs",
+ 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_Clubs", x => x.Id);
+ });
+
migrationBuilder.CreateTable(
name: "Interests",
columns: table => new
@@ -27,7 +40,7 @@ namespace SchoolDatabaseImplement.Migrations
});
migrationBuilder.CreateTable(
- name: "Material",
+ name: "Materials",
columns: table => new
{
Id = table.Column(type: "int", nullable: false)
@@ -36,7 +49,7 @@ namespace SchoolDatabaseImplement.Migrations
},
constraints: table =>
{
- table.PrimaryKey("PK_Material", x => x.Id);
+ table.PrimaryKey("PK_Materials", x => x.Id);
});
migrationBuilder.CreateTable(
@@ -57,7 +70,7 @@ namespace SchoolDatabaseImplement.Migrations
});
migrationBuilder.CreateTable(
- name: "InterestMaterial",
+ name: "InterestMaterials",
columns: table => new
{
Id = table.Column(type: "int", nullable: false)
@@ -67,17 +80,17 @@ namespace SchoolDatabaseImplement.Migrations
},
constraints: table =>
{
- table.PrimaryKey("PK_InterestMaterial", x => x.Id);
+ table.PrimaryKey("PK_InterestMaterials", x => x.Id);
table.ForeignKey(
- name: "FK_InterestMaterial_Interests_InterestId",
+ name: "FK_InterestMaterials_Interests_InterestId",
column: x => x.InterestId,
principalTable: "Interests",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
- name: "FK_InterestMaterial_Material_MaterialId",
+ name: "FK_InterestMaterials_Materials_MaterialId",
column: x => x.MaterialId,
- principalTable: "Material",
+ principalTable: "Materials",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
@@ -125,6 +138,32 @@ namespace SchoolDatabaseImplement.Migrations
onDelete: ReferentialAction.Cascade);
});
+ migrationBuilder.CreateTable(
+ name: "ClubLessons",
+ columns: table => new
+ {
+ Id = table.Column(type: "int", nullable: false)
+ .Annotation("SqlServer:Identity", "1, 1"),
+ ClubId = table.Column(type: "int", nullable: false),
+ LessonId = table.Column(type: "int", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_ClubLessons", x => x.Id);
+ table.ForeignKey(
+ name: "FK_ClubLessons_Clubs_ClubId",
+ column: x => x.ClubId,
+ principalTable: "Clubs",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ table.ForeignKey(
+ name: "FK_ClubLessons_Lessons_LessonId",
+ column: x => x.LessonId,
+ principalTable: "Lessons",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
migrationBuilder.CreateTable(
name: "InterestLessons",
columns: table => new
@@ -156,6 +195,16 @@ namespace SchoolDatabaseImplement.Migrations
table: "Achievements",
column: "LessonId");
+ migrationBuilder.CreateIndex(
+ name: "IX_ClubLessons_ClubId",
+ table: "ClubLessons",
+ column: "ClubId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_ClubLessons_LessonId",
+ table: "ClubLessons",
+ column: "LessonId");
+
migrationBuilder.CreateIndex(
name: "IX_InterestLessons_InterestId",
table: "InterestLessons",
@@ -167,13 +216,13 @@ namespace SchoolDatabaseImplement.Migrations
column: "LessonId");
migrationBuilder.CreateIndex(
- name: "IX_InterestMaterial_InterestId",
- table: "InterestMaterial",
+ name: "IX_InterestMaterials_InterestId",
+ table: "InterestMaterials",
column: "InterestId");
migrationBuilder.CreateIndex(
- name: "IX_InterestMaterial_MaterialId",
- table: "InterestMaterial",
+ name: "IX_InterestMaterials_MaterialId",
+ table: "InterestMaterials",
column: "MaterialId");
migrationBuilder.CreateIndex(
@@ -188,11 +237,17 @@ namespace SchoolDatabaseImplement.Migrations
migrationBuilder.DropTable(
name: "Achievements");
+ migrationBuilder.DropTable(
+ name: "ClubLessons");
+
migrationBuilder.DropTable(
name: "InterestLessons");
migrationBuilder.DropTable(
- name: "InterestMaterial");
+ name: "InterestMaterials");
+
+ migrationBuilder.DropTable(
+ name: "Clubs");
migrationBuilder.DropTable(
name: "Lessons");
@@ -201,7 +256,7 @@ namespace SchoolDatabaseImplement.Migrations
name: "Interests");
migrationBuilder.DropTable(
- name: "Material");
+ name: "Materials");
migrationBuilder.DropTable(
name: "Users");
diff --git a/School/SchoolDatabaseImplement/Migrations/SchoolDatabaseModelSnapshot.cs b/School/SchoolDatabaseImplement/Migrations/SchoolDatabaseModelSnapshot.cs
index 6dd339e..44329f5 100644
--- a/School/SchoolDatabaseImplement/Migrations/SchoolDatabaseModelSnapshot.cs
+++ b/School/SchoolDatabaseImplement/Migrations/SchoolDatabaseModelSnapshot.cs
@@ -51,6 +51,46 @@ namespace SchoolDatabaseImplement.Migrations
b.ToTable("Achievements");
});
+ modelBuilder.Entity("SchoolDatabaseImplement.Models.Club", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.HasKey("Id");
+
+ b.ToTable("Clubs");
+ });
+
+ modelBuilder.Entity("SchoolDatabaseImplement.Models.ClubLesson", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
+
+ b.Property("ClubId")
+ .HasColumnType("int");
+
+ b.Property("LessonId")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ClubId");
+
+ b.HasIndex("LessonId");
+
+ b.ToTable("ClubLessons");
+ });
+
modelBuilder.Entity("SchoolDatabaseImplement.Models.Interest", b =>
{
b.Property("Id")
@@ -119,7 +159,7 @@ namespace SchoolDatabaseImplement.Migrations
b.HasIndex("MaterialId");
- b.ToTable("InterestMaterial");
+ b.ToTable("InterestMaterials");
});
modelBuilder.Entity("SchoolDatabaseImplement.Models.Lesson", b =>
@@ -160,7 +200,7 @@ namespace SchoolDatabaseImplement.Migrations
b.HasKey("Id");
- b.ToTable("Material");
+ b.ToTable("Materials");
});
modelBuilder.Entity("SchoolDatabaseImplement.Models.User", b =>
@@ -206,6 +246,25 @@ namespace SchoolDatabaseImplement.Migrations
b.Navigation("Lesson");
});
+ modelBuilder.Entity("SchoolDatabaseImplement.Models.ClubLesson", b =>
+ {
+ b.HasOne("SchoolDatabaseImplement.Models.Club", "Club")
+ .WithMany("Lessons")
+ .HasForeignKey("ClubId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("SchoolDatabaseImplement.Models.Lesson", "Lesson")
+ .WithMany()
+ .HasForeignKey("LessonId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Club");
+
+ b.Navigation("Lesson");
+ });
+
modelBuilder.Entity("SchoolDatabaseImplement.Models.InterestLesson", b =>
{
b.HasOne("SchoolDatabaseImplement.Models.Interest", "Interest")
@@ -255,6 +314,11 @@ namespace SchoolDatabaseImplement.Migrations
b.Navigation("User");
});
+ modelBuilder.Entity("SchoolDatabaseImplement.Models.Club", b =>
+ {
+ b.Navigation("Lessons");
+ });
+
modelBuilder.Entity("SchoolDatabaseImplement.Models.Interest", b =>
{
b.Navigation("Lessons");
diff --git a/School/SchoolDatabaseImplement/SchoolDatabase.cs b/School/SchoolDatabaseImplement/SchoolDatabase.cs
index feaa016..d7899f6 100644
--- a/School/SchoolDatabaseImplement/SchoolDatabase.cs
+++ b/School/SchoolDatabaseImplement/SchoolDatabase.cs
@@ -25,6 +25,11 @@ namespace SchoolDatabaseImplement
public virtual DbSet InterestLessons { set; get; }
public virtual DbSet Interests { set; get; }
public virtual DbSet Achievements { set; get; }
+ public virtual DbSet Clubs { set; get; }
+ public virtual DbSet ClubLessons { set; get; }
+ public virtual DbSet Materials { set; get; }
+
+ public virtual DbSet InterestMaterials { set; get; }
}
}