123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- using System;
- using System.Collections.Generic;
- using Microsoft.EntityFrameworkCore;
- namespace pr13.Models;
- public partial class PostgresContext : DbContext
- {
- public PostgresContext()
- {
- }
- public PostgresContext(DbContextOptions<PostgresContext> options)
- : base(options)
- {
- }
- public virtual DbSet<Course> Courses { get; set; }
- public virtual DbSet<Gender> Genders { get; set; }
- public virtual DbSet<Role> Roles { get; set; }
- public virtual DbSet<Teacher> Teachers { get; set; }
- public virtual DbSet<TeachersCourse> TeachersCourses { 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 http://go.microsoft.com/fwlink/?LinkId=723263.
- => optionsBuilder.UseNpgsql("Host=edu.pg.ngknn.local;Port=5432;Database=Smirnov2;Username=43P;Password=444444");
- protected override void OnModelCreating(ModelBuilder modelBuilder)
- {
- modelBuilder.HasPostgresExtension("pg_catalog", "adminpack");
- modelBuilder.Entity<Course>(entity =>
- {
- entity.HasKey(e => e.Idcurs).HasName("newtable_pk");
- entity.ToTable("courses");
- entity.Property(e => e.Idcurs)
- .UseIdentityAlwaysColumn()
- .HasColumnName("idcurs");
- entity.Property(e => e.Course1)
- .HasColumnType("character varying")
- .HasColumnName("curs");
- });
- modelBuilder.Entity<Gender>(entity =>
- {
- entity.HasKey(e => e.Id).HasName("genders_pk");
- entity.ToTable("gender");
- entity.Property(e => e.Id)
- .UseIdentityAlwaysColumn()
- .HasColumnName("idgender");
- entity.Property(e => e.Gender1)
- .HasColumnType("character varying")
- .HasColumnName("namegender");
- });
- modelBuilder.Entity<Role>(entity =>
- {
- entity.HasKey(e => e.IdRole).HasName("roles_pk");
- entity.ToTable("roles");
- entity.Property(e => e.IdRole)
- .UseIdentityAlwaysColumn()
- .HasColumnName("id_role");
- entity.Property(e => e.Role1)
- .HasColumnType("character varying")
- .HasColumnName("role");
- });
- modelBuilder.Entity<Teacher>(entity =>
- {
- entity.HasKey(e => e.IdTeacher).HasName("teachers_pk");
- entity.ToTable("teachers");
- entity.Property(e => e.IdTeacher)
- .ValueGeneratedOnAdd()
- .UseIdentityAlwaysColumn()
- .HasColumnName("idteacher");
- entity.Property(e => e.Birthdate)
- .HasColumnType("timestamp without time zone")
- .HasColumnName("dr");
- entity.Property(e => e.Email)
- .HasColumnType("character varying")
- .HasColumnName("mail");
- entity.Property(e => e.Expirience).HasColumnName("stash");
- entity.Property(e => e.IdGender).HasColumnName("idgender");
- entity.Property(e => e.Name)
- .HasColumnType("character varying")
- .HasColumnName("name");
- entity.Property(e => e.Patronymic)
- .HasColumnType("character varying")
- .HasColumnName("otchestvo");
- entity.Property(e => e.Phone)
- .HasColumnType("character varying")
- .HasColumnName("phone");
- entity.Property(e => e.Surname)
- .HasColumnType("character varying")
- .HasColumnName("familia");
- entity.HasOne(d => d.IdGenderNavigation).WithMany(p => p.Teachers)
- .HasForeignKey(d => d.IdGender)
- .HasConstraintName("teacher_fk");
- entity.HasOne(d => d.IdTeacherNavigation).WithOne(p => p.Teacher)
- .HasForeignKey<Teacher>(d => d.IdTeacher)
- .HasConstraintName("teacher_fk1");
- });
- modelBuilder.Entity<TeachersCourse>(entity =>
- {
- entity.HasKey(e => e.Id).HasName("teachers_courses_pk");
- entity.ToTable("teachers_courses");
- entity.Property(e => e.Id)
- .UseIdentityAlwaysColumn()
- .HasColumnName("id");
- entity.Property(e => e.Hours).HasColumnName("time");
- entity.Property(e => e.IdCourse).HasColumnName("idcurs");
- entity.Property(e => e.IdTeacher).HasColumnName("idteacher");
- entity.HasOne(d => d.IdCourseNavigation).WithMany(p => p.TeachersCourses)
- .HasForeignKey(d => d.IdCourse)
- .HasConstraintName("teachers_courses_fk_1");
- entity.HasOne(d => d.IdTeacherNavigation).WithMany(p => p.TeachersCourses)
- .HasForeignKey(d => d.IdTeacher)
- .HasConstraintName("teachers_courses_fk");
- });
- modelBuilder.Entity<User>(entity =>
- {
- entity.HasKey(e => e.IdUser).HasName("users_pk");
- entity.ToTable("users");
- entity.Property(e => e.IdUser)
- .UseIdentityAlwaysColumn()
- .HasColumnName("iduser");
- entity.Property(e => e.IdRole).HasColumnName("idrol");
- entity.Property(e => e.Login)
- .HasColumnType("character varying")
- .HasColumnName("login");
- entity.Property(e => e.Password)
- .HasColumnType("character varying")
- .HasColumnName("parol");
- entity.HasOne(d => d.IdRoleNavigation).WithMany(p => p.Users)
- .HasForeignKey(d => d.IdRole)
- .HasConstraintName("users_fk");
- });
- modelBuilder.HasSequence("courses_id_seq").HasMax(2147483647L);
- modelBuilder.HasSequence("genders_id_seq").HasMax(2147483647L);
- modelBuilder.HasSequence("roles_id_role_seq").HasMax(2147483647L);
- modelBuilder.HasSequence("teachers_courses_id_seq").HasMax(2147483647L);
- modelBuilder.HasSequence("teachers_id_seq").HasMax(2147483647L);
- modelBuilder.HasSequence("users_id_user_seq").HasMax(2147483647L);
- OnModelCreatingPartial(modelBuilder);
- }
- partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
- }
|