123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- using System;
- using System.Collections.Generic;
- using Microsoft.EntityFrameworkCore;
- namespace Teachers.Models;
- public partial class _43pTryaninaContext : DbContext
- {
- public _43pTryaninaContext()
- {
- }
- public _43pTryaninaContext(DbContextOptions<_43pTryaninaContext> options)
- : base(options)
- {
- }
- public virtual DbSet<Course> Courses { get; set; }
- public virtual DbSet<Gender> Genders { get; set; }
- public virtual DbSet<Subject> Subjects { get; set; }
- public virtual DbSet<SubjectsTaught> SubjectsTaughts { get; set; }
- public virtual DbSet<Teacher> Teachers { get; set; }
- public virtual DbSet<TeacherCourse> TeacherCourses { 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=edu.pg.ngknn.ru;Port=5442;Database=43P_Tryanina;Username=43P;Password=444444");
- protected override void OnModelCreating(ModelBuilder modelBuilder)
- {
- modelBuilder.Entity<Course>(entity =>
- {
- entity.HasKey(e => e.Id).HasName("subjects_pk_1");
- entity.ToTable("courses");
- entity.Property(e => e.Id).HasColumnName("id");
- entity.Property(e => e.Duration).HasColumnName("duration");
- entity.Property(e => e.Name)
- .HasMaxLength(100)
- .HasColumnName("name");
- });
- modelBuilder.Entity<Gender>(entity =>
- {
- entity.HasKey(e => e.Id).HasName("genders_pk");
- entity.ToTable("genders");
- entity.Property(e => e.Id).HasColumnName("id");
- entity.Property(e => e.Gender1)
- .HasMaxLength(10)
- .HasColumnName("gender");
- });
- modelBuilder.Entity<Subject>(entity =>
- {
- entity.HasKey(e => e.Id).HasName("subjects_pk");
- entity.ToTable("subjects");
- entity.Property(e => e.Id).HasColumnName("id");
- entity.Property(e => e.Name)
- .HasMaxLength(50)
- .HasColumnName("name");
- });
- modelBuilder.Entity<SubjectsTaught>(entity =>
- {
- entity.HasKey(e => e.IdSt).HasName("subjects_taught_pk");
- entity.ToTable("subjects_taught");
- entity.Property(e => e.IdSt).HasColumnName("id_st");
- entity.Property(e => e.IdSubject)
- .ValueGeneratedOnAdd()
- .HasColumnName("id_subject");
- entity.Property(e => e.IdTeacher)
- .ValueGeneratedOnAdd()
- .HasColumnName("id_teacher");
- entity.HasOne(d => d.IdSubjectNavigation).WithMany(p => p.SubjectsTaughts)
- .HasForeignKey(d => d.IdSubject)
- .HasConstraintName("subjects_taught_subjects_fk");
- entity.HasOne(d => d.IdTeacherNavigation).WithMany(p => p.SubjectsTaughts)
- .HasForeignKey(d => d.IdTeacher)
- .HasConstraintName("subjects_taught_teachers_fk");
- });
- modelBuilder.Entity<Teacher>(entity =>
- {
- entity.HasKey(e => e.Id).HasName("teachers_pk");
- entity.ToTable("teachers");
- entity.Property(e => e.Id).HasColumnName("id");
- entity.Property(e => e.Birthday)
- .HasColumnType("timestamp without time zone")
- .HasColumnName("birthday");
- entity.Property(e => e.Email)
- .HasMaxLength(100)
- .HasColumnName("email");
- entity.Property(e => e.Experience).HasColumnName("experience");
- entity.Property(e => e.Gender)
- .HasDefaultValue(1)
- .HasColumnName("gender");
- entity.Property(e => e.Name)
- .HasMaxLength(20)
- .HasColumnName("name");
- entity.Property(e => e.Patronymic)
- .HasMaxLength(20)
- .HasColumnName("patronymic");
- entity.Property(e => e.Phone)
- .HasMaxLength(25)
- .HasColumnName("phone");
- entity.Property(e => e.Surname)
- .HasMaxLength(20)
- .HasColumnName("surname");
- entity.HasOne(d => d.GenderNavigation).WithMany(p => p.Teachers)
- .HasForeignKey(d => d.Gender)
- .HasConstraintName("teachers_genders_fk");
- });
- modelBuilder.Entity<TeacherCourse>(entity =>
- {
- entity.HasKey(e => e.IdTc).HasName("teacher_courses_pk");
- entity.ToTable("teacher_courses");
- entity.Property(e => e.IdTc).HasColumnName("id_tc");
- entity.Property(e => e.IdCourse)
- .ValueGeneratedOnAdd()
- .HasColumnName("id_course");
- entity.Property(e => e.IdTeacher)
- .ValueGeneratedOnAdd()
- .HasColumnName("id_teacher");
- entity.HasOne(d => d.IdCourseNavigation).WithMany(p => p.TeacherCourses)
- .HasForeignKey(d => d.IdCourse)
- .HasConstraintName("teacher_courses_courses_fk");
- entity.HasOne(d => d.IdTeacherNavigation).WithMany(p => p.TeacherCourses)
- .HasForeignKey(d => d.IdTeacher)
- .HasConstraintName("teacher_courses_teachers_fk");
- });
- OnModelCreatingPartial(modelBuilder);
- }
- partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
- }
|