214 lines
7.9 KiB
C#
214 lines
7.9 KiB
C#
![]() |
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using Microsoft.EntityFrameworkCore;
|
|||
|
|
|||
|
namespace kursovaya.Models;
|
|||
|
|
|||
|
public partial class DatabaseContext : DbContext
|
|||
|
{
|
|||
|
public DatabaseContext()
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
public DatabaseContext(DbContextOptions<DatabaseContext> options)
|
|||
|
: base(options)
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
public virtual DbSet<Attestation> Attestations { get; set; }
|
|||
|
|
|||
|
public virtual DbSet<Discipline> Disciplines { get; set; }
|
|||
|
|
|||
|
public virtual DbSet<DisciplineTeacher> DisciplineTeachers { get; set; }
|
|||
|
|
|||
|
public virtual DbSet<FormAttest> FormAttests { get; set; }
|
|||
|
|
|||
|
public virtual DbSet<Group> Groups { get; set; }
|
|||
|
|
|||
|
public virtual DbSet<Role> Roles { get; set; }
|
|||
|
|
|||
|
public virtual DbSet<Student> Students { get; set; }
|
|||
|
|
|||
|
public virtual DbSet<Teacher> Teachers { get; set; }
|
|||
|
|
|||
|
public virtual DbSet<User> Users { get; set; }
|
|||
|
|
|||
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
|||
|
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see https://go.microsoft.com/fwlink/?LinkId=723263.
|
|||
|
=> optionsBuilder.UseNpgsql("Host=localhost;Database=postgres;Username=postgres;Password=5432");
|
|||
|
|
|||
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|||
|
{
|
|||
|
modelBuilder.Entity<Attestation>(entity =>
|
|||
|
{
|
|||
|
entity.HasKey(e => new { e.IdUser, e.IdDiscipline }).HasName("attestation_pkey");
|
|||
|
|
|||
|
entity.ToTable("attestation");
|
|||
|
|
|||
|
entity.Property(e => e.IdUser).HasColumnName("id_user");
|
|||
|
entity.Property(e => e.IdDiscipline).HasColumnName("id_discipline");
|
|||
|
entity.Property(e => e.AttestFirst).HasColumnName("attest_first");
|
|||
|
entity.Property(e => e.AttestSecond).HasColumnName("attest_second");
|
|||
|
entity.Property(e => e.AttestThird).HasColumnName("attest_third");
|
|||
|
entity.Property(e => e.Grade)
|
|||
|
.HasMaxLength(255)
|
|||
|
.HasColumnName("grade");
|
|||
|
entity.Property(e => e.Total).HasColumnName("total");
|
|||
|
|
|||
|
entity.HasOne(d => d.IdDisciplineNavigation).WithMany(p => p.Attestations)
|
|||
|
.HasForeignKey(d => d.IdDiscipline)
|
|||
|
.HasConstraintName("attestation_id_discipline_fkey");
|
|||
|
|
|||
|
entity.HasOne(d => d.IdUserNavigation).WithMany(p => p.Attestations)
|
|||
|
.HasForeignKey(d => d.IdUser)
|
|||
|
.HasConstraintName("attestation_id_user_fkey");
|
|||
|
});
|
|||
|
|
|||
|
modelBuilder.Entity<Discipline>(entity =>
|
|||
|
{
|
|||
|
entity.HasKey(e => e.Id).HasName("discipline_pkey");
|
|||
|
|
|||
|
entity.ToTable("discipline");
|
|||
|
|
|||
|
entity.Property(e => e.Id).HasColumnName("id");
|
|||
|
entity.Property(e => e.IdFormAttest).HasColumnName("id_form_attest");
|
|||
|
entity.Property(e => e.Name)
|
|||
|
.HasMaxLength(255)
|
|||
|
.HasColumnName("name");
|
|||
|
|
|||
|
entity.HasOne(d => d.IdFormAttestNavigation).WithMany(p => p.Disciplines)
|
|||
|
.HasForeignKey(d => d.IdFormAttest)
|
|||
|
.HasConstraintName("discipline_id_form_attest_fkey");
|
|||
|
});
|
|||
|
|
|||
|
modelBuilder.Entity<DisciplineTeacher>(entity =>
|
|||
|
{
|
|||
|
entity.HasKey(e => e.Id).HasName("discipline_teachers_pkey");
|
|||
|
|
|||
|
entity.ToTable("discipline_teachers");
|
|||
|
|
|||
|
entity.HasIndex(e => new { e.IdDiscipline, e.IdTeacher }, "unique_discipline_teacher").IsUnique();
|
|||
|
|
|||
|
entity.Property(e => e.Id).HasColumnName("id");
|
|||
|
entity.Property(e => e.IdDiscipline).HasColumnName("id_discipline");
|
|||
|
entity.Property(e => e.IdTeacher).HasColumnName("id_teacher");
|
|||
|
|
|||
|
entity.HasOne(d => d.IdDisciplineNavigation).WithMany(p => p.DisciplineTeachers)
|
|||
|
.HasForeignKey(d => d.IdDiscipline)
|
|||
|
.HasConstraintName("discipline_teachers_id_discipline_fkey");
|
|||
|
|
|||
|
entity.HasOne(d => d.IdTeacherNavigation).WithMany(p => p.DisciplineTeachers)
|
|||
|
.HasForeignKey(d => d.IdTeacher)
|
|||
|
.HasConstraintName("discipline_teachers_id_teacher_fkey");
|
|||
|
});
|
|||
|
|
|||
|
modelBuilder.Entity<FormAttest>(entity =>
|
|||
|
{
|
|||
|
entity.HasKey(e => e.Id).HasName("form_attest_pkey");
|
|||
|
|
|||
|
entity.ToTable("form_attest");
|
|||
|
|
|||
|
entity.Property(e => e.Id).HasColumnName("id");
|
|||
|
entity.Property(e => e.Name)
|
|||
|
.HasMaxLength(255)
|
|||
|
.HasColumnName("name");
|
|||
|
});
|
|||
|
|
|||
|
modelBuilder.Entity<Group>(entity =>
|
|||
|
{
|
|||
|
entity.HasKey(e => e.Id).HasName("groups_pkey");
|
|||
|
|
|||
|
entity.ToTable("groups");
|
|||
|
|
|||
|
entity.Property(e => e.Id).HasColumnName("id");
|
|||
|
entity.Property(e => e.YearAdmission).HasColumnName("year_admission");
|
|||
|
});
|
|||
|
|
|||
|
modelBuilder.Entity<Role>(entity =>
|
|||
|
{
|
|||
|
entity.HasKey(e => e.Id).HasName("roles_pkey");
|
|||
|
|
|||
|
entity.ToTable("roles");
|
|||
|
|
|||
|
entity.Property(e => e.Id).HasColumnName("id");
|
|||
|
entity.Property(e => e.RoleName)
|
|||
|
.HasMaxLength(255)
|
|||
|
.HasColumnName("role_name");
|
|||
|
});
|
|||
|
|
|||
|
modelBuilder.Entity<Student>(entity =>
|
|||
|
{
|
|||
|
entity.HasKey(e => e.Id).HasName("students_pkey");
|
|||
|
|
|||
|
entity.ToTable("students");
|
|||
|
|
|||
|
entity.Property(e => e.Id).HasColumnName("id");
|
|||
|
entity.Property(e => e.Fio)
|
|||
|
.HasMaxLength(255)
|
|||
|
.HasColumnName("fio");
|
|||
|
entity.Property(e => e.IdGroup).HasColumnName("id_group");
|
|||
|
entity.Property(e => e.Login)
|
|||
|
.HasMaxLength(255)
|
|||
|
.HasColumnName("login");
|
|||
|
|
|||
|
entity.HasOne(d => d.IdGroupNavigation).WithMany(p => p.Students)
|
|||
|
.HasForeignKey(d => d.IdGroup)
|
|||
|
.HasConstraintName("students_id_group_fkey");
|
|||
|
|
|||
|
entity.HasOne(d => d.LoginNavigation).WithMany(p => p.Students)
|
|||
|
.HasPrincipalKey(p => p.Login)
|
|||
|
.HasForeignKey(d => d.Login)
|
|||
|
.HasConstraintName("students_login_fkey");
|
|||
|
});
|
|||
|
|
|||
|
modelBuilder.Entity<Teacher>(entity =>
|
|||
|
{
|
|||
|
entity.HasKey(e => e.Id).HasName("teachers_pkey");
|
|||
|
|
|||
|
entity.ToTable("teachers");
|
|||
|
|
|||
|
entity.Property(e => e.Id).HasColumnName("id");
|
|||
|
entity.Property(e => e.Fio)
|
|||
|
.HasMaxLength(255)
|
|||
|
.HasColumnName("fio");
|
|||
|
entity.Property(e => e.Login)
|
|||
|
.HasMaxLength(255)
|
|||
|
.HasColumnName("login");
|
|||
|
|
|||
|
entity.HasOne(d => d.LoginNavigation).WithMany(p => p.Teachers)
|
|||
|
.HasPrincipalKey(p => p.Login)
|
|||
|
.HasForeignKey(d => d.Login)
|
|||
|
.HasConstraintName("teachers_login_fkey");
|
|||
|
});
|
|||
|
|
|||
|
modelBuilder.Entity<User>(entity =>
|
|||
|
{
|
|||
|
entity.HasKey(e => e.Id).HasName("users_pkey");
|
|||
|
|
|||
|
entity.ToTable("users");
|
|||
|
|
|||
|
entity.HasIndex(e => e.Login, "login").IsUnique();
|
|||
|
|
|||
|
entity.Property(e => e.Id).HasColumnName("id");
|
|||
|
entity.Property(e => e.Email)
|
|||
|
.HasMaxLength(255)
|
|||
|
.HasColumnName("email");
|
|||
|
entity.Property(e => e.Login)
|
|||
|
.HasMaxLength(255)
|
|||
|
.HasColumnName("login");
|
|||
|
entity.Property(e => e.Password)
|
|||
|
.HasMaxLength(255)
|
|||
|
.HasColumnName("password");
|
|||
|
entity.Property(e => e.RoleId).HasColumnName("role_id");
|
|||
|
|
|||
|
entity.HasOne(d => d.Role).WithMany(p => p.Users)
|
|||
|
.HasForeignKey(d => d.RoleId)
|
|||
|
.HasConstraintName("users_role_id_fkey");
|
|||
|
});
|
|||
|
|
|||
|
OnModelCreatingPartial(modelBuilder);
|
|||
|
}
|
|||
|
|
|||
|
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
|
|||
|
}
|