Попытка исправить другую ошибку

This commit is contained in:
DyCTaTOR 2024-05-18 20:48:42 +04:00
parent f897516f3e
commit 2a5e8e3372
4 changed files with 973 additions and 459 deletions

View File

@ -0,0 +1,467 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using UniversityDatabaseImplement;
#nullable disable
namespace UniversityDatabaseImplement.Migrations
{
[DbContext(typeof(UniversityDatabase))]
[Migration("20240518164251_newMigration")]
partial class newMigration
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.4")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("UniversityDatabaseImplement.Models.Attestation", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("FormOfEvaluation")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("Score")
.HasColumnType("int");
b.Property<int>("StudentId")
.HasColumnType("int");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("StudentId");
b.HasIndex("UserId");
b.ToTable("Attestations");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.Discipline", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<DateOnly>("Date")
.HasColumnType("date");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("TeacherId")
.HasColumnType("int");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("TeacherId");
b.HasIndex("UserId");
b.ToTable("Disciplines");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.PlanOfStudy", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<DateOnly>("Date")
.HasColumnType("date");
b.Property<string>("FormOfStudy")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Profile")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("PlanOfStudys");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.PlanOfStudyTeacher", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("PlanOfStudyId")
.HasColumnType("int");
b.Property<int>("TeacherId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("PlanOfStudyId");
b.HasIndex("TeacherId");
b.ToTable("PlanOfStudyTeachers");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.Statement", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<DateTime>("Date")
.HasColumnType("datetime2");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("TeacherId")
.HasColumnType("int");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("TeacherId");
b.HasIndex("UserId");
b.ToTable("Statements");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.Student", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("PhoneNumber")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("PlanOfStudyId")
.HasColumnType("int");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("PlanOfStudyId");
b.HasIndex("UserId");
b.ToTable("Students");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.StudentDiscipline", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("DisciplineId")
.HasColumnType("int");
b.Property<int>("StudentId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("DisciplineId");
b.HasIndex("StudentId");
b.ToTable("StudentDisciplines");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.Teacher", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("AcademicDegree")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Position")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Teachers");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.User", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Email")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Login")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("Role")
.HasColumnType("int");
b.HasKey("Id");
b.ToTable("Users");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.Attestation", b =>
{
b.HasOne("UniversityDatabaseImplement.Models.Student", "Student")
.WithMany("Attestations")
.HasForeignKey("StudentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("UniversityDatabaseImplement.Models.User", "User")
.WithMany("Attestations")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Student");
b.Navigation("User");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.Discipline", b =>
{
b.HasOne("UniversityDatabaseImplement.Models.Teacher", "Teacher")
.WithMany("Disciplines")
.HasForeignKey("TeacherId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("UniversityDatabaseImplement.Models.User", "User")
.WithMany("Disciplines")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Teacher");
b.Navigation("User");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.PlanOfStudy", b =>
{
b.HasOne("UniversityDatabaseImplement.Models.User", "User")
.WithMany("PlanOfStudys")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.PlanOfStudyTeacher", b =>
{
b.HasOne("UniversityDatabaseImplement.Models.PlanOfStudy", "PlanOfStudy")
.WithMany("Teachers")
.HasForeignKey("PlanOfStudyId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("UniversityDatabaseImplement.Models.Teacher", "Teacher")
.WithMany("PlanOfStudyTeachers")
.HasForeignKey("TeacherId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("PlanOfStudy");
b.Navigation("Teacher");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.Statement", b =>
{
b.HasOne("UniversityDatabaseImplement.Models.Teacher", "Teacher")
.WithMany("Statements")
.HasForeignKey("TeacherId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("UniversityDatabaseImplement.Models.User", "User")
.WithMany("Statements")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Teacher");
b.Navigation("User");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.Student", b =>
{
b.HasOne("UniversityDatabaseImplement.Models.PlanOfStudy", "PlanOfStudy")
.WithMany("Students")
.HasForeignKey("PlanOfStudyId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("UniversityDatabaseImplement.Models.User", "User")
.WithMany("Students")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("PlanOfStudy");
b.Navigation("User");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.StudentDiscipline", b =>
{
b.HasOne("UniversityDatabaseImplement.Models.Discipline", "Discipline")
.WithMany("Students")
.HasForeignKey("DisciplineId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("UniversityDatabaseImplement.Models.Student", "Student")
.WithMany("StudentDiscipline")
.HasForeignKey("StudentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Discipline");
b.Navigation("Student");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.Teacher", b =>
{
b.HasOne("UniversityDatabaseImplement.Models.User", "User")
.WithMany("Teachers")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.Discipline", b =>
{
b.Navigation("Students");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.PlanOfStudy", b =>
{
b.Navigation("Students");
b.Navigation("Teachers");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.Student", b =>
{
b.Navigation("Attestations");
b.Navigation("StudentDiscipline");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.Teacher", b =>
{
b.Navigation("Disciplines");
b.Navigation("PlanOfStudyTeachers");
b.Navigation("Statements");
});
modelBuilder.Entity("UniversityDatabaseImplement.Models.User", b =>
{
b.Navigation("Attestations");
b.Navigation("Disciplines");
b.Navigation("PlanOfStudys");
b.Navigation("Statements");
b.Navigation("Students");
b.Navigation("Teachers");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,41 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace UniversityDatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class newMigration : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<DateOnly>(
name: "Date",
table: "PlanOfStudys",
type: "date",
nullable: false,
defaultValue: new DateOnly(1, 1, 1));
migrationBuilder.AddColumn<DateOnly>(
name: "Date",
table: "Disciplines",
type: "date",
nullable: false,
defaultValue: new DateOnly(1, 1, 1));
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Date",
table: "PlanOfStudys");
migrationBuilder.DropColumn(
name: "Date",
table: "Disciplines");
}
}
}

View File

@ -60,6 +60,9 @@ namespace UniversityDatabaseImplement.Migrations
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id")); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<DateOnly>("Date")
.HasColumnType("date");
b.Property<string>("Description") b.Property<string>("Description")
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
@ -91,6 +94,9 @@ namespace UniversityDatabaseImplement.Migrations
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id")); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<DateOnly>("Date")
.HasColumnType("date");
b.Property<string>("FormOfStudy") b.Property<string>("FormOfStudy")
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");

View File

@ -11,7 +11,7 @@ namespace UniversityDatabaseImplement
if (optionsBuilder.IsConfigured == false) if (optionsBuilder.IsConfigured == false)
{ {
//Возможно понадобится писать вместо (localdb) название пк, вот пк Егора: DESKTOP-N8BRIPR; other-name: LAPTOP-DYCTATOR; other-name: DyCTaTOR //Возможно понадобится писать вместо (localdb) название пк, вот пк Егора: DESKTOP-N8BRIPR; other-name: LAPTOP-DYCTATOR; other-name: DyCTaTOR
optionsBuilder.UseSqlServer(@"Data Source=DyCTaTOR\SQLEXPRESS;Initial Catalog=UniversityDatabaseFull;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True"); optionsBuilder.UseSqlServer(@"Data Source=localhost\SQLEXPRESS;Initial Catalog=UniversityDatabaseFull;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
} }
base.OnConfiguring(optionsBuilder); base.OnConfiguring(optionsBuilder);
} }