123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169 |
- using System;
- using System.Collections.Generic;
- using Microsoft.EntityFrameworkCore;
- namespace AvaloniaApplication1.Models;
- public partial class ScoolContext : DbContext
- {
- public ScoolContext()
- {
- }
- public ScoolContext(DbContextOptions<ScoolContext> 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=43P_Ermolin2;Username=43P;Password=444444");
- protected override void OnModelCreating(ModelBuilder modelBuilder)
- {
- modelBuilder.Entity<Course>(entity =>
- {
- entity.HasKey(e => e.Id).HasName("courses_pk");
- entity.ToTable("courses");
- entity.Property(e => e.Id)
- .UseIdentityAlwaysColumn()
- .HasColumnName("id");
- entity.Property(e => e.Course1)
- .HasColumnType("character varying")
- .HasColumnName("course");
- });
- modelBuilder.Entity<Gender>(entity =>
- {
- entity.HasKey(e => e.Id).HasName("genders_pk");
- entity.ToTable("genders");
- entity.Property(e => e.Id)
- .UseIdentityAlwaysColumn()
- .HasColumnName("id");
- entity.Property(e => e.Gender1)
- .HasColumnType("character varying")
- .HasColumnName("gender");
- });
- 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.Id).HasName("teachers_pk");
- entity.ToTable("teachers");
- entity.Property(e => e.Id)
- .ValueGeneratedOnAdd()
- .UseIdentityAlwaysColumn()
- .HasColumnName("id");
- entity.Property(e => e.Birthdate)
- .HasColumnType("timestamp without time zone")
- .HasColumnName("birthdate");
- entity.Property(e => e.Email)
- .HasColumnType("character varying")
- .HasColumnName("email");
- entity.Property(e => e.Expirience).HasColumnName("expirience");
- entity.Property(e => e.IdGender).HasColumnName("id_gender");
- entity.Property(e => e.Name)
- .HasColumnType("character varying")
- .HasColumnName("name");
- entity.Property(e => e.Patronymic)
- .HasColumnType("character varying")
- .HasColumnName("patronymic");
- entity.Property(e => e.Phone)
- .HasColumnType("character varying")
- .HasColumnName("phone");
- entity.Property(e => e.Surname)
- .HasColumnType("character varying")
- .HasColumnName("surname");
- entity.HasOne(d => d.IdNavigation).WithOne(p => p.Teacher)
- .HasForeignKey<Teacher>(d => d.Id)
- .OnDelete(DeleteBehavior.ClientSetNull)
- .HasConstraintName("teachers_users_fk");
- entity.HasOne(d => d.IdGenderNavigation).WithMany(p => p.Teachers)
- .HasForeignKey(d => d.IdGender)
- .HasConstraintName("teachers_genders_fk");
- });
- modelBuilder.Entity<TeachersCourse>(entity =>
- {
- entity.HasKey(e => e.Id).HasName("newtable_pk");
- entity.ToTable("teachers_courses");
- entity.Property(e => e.Id)
- .UseIdentityAlwaysColumn()
- .HasColumnName("id");
- entity.Property(e => e.Hours).HasColumnName("hours");
- entity.Property(e => e.IdCourse).HasColumnName("id_course");
- entity.Property(e => e.IdTeacher).HasColumnName("id_teacher");
- entity.HasOne(d => d.IdCourseNavigation).WithMany(p => p.TeachersCourses)
- .HasForeignKey(d => d.IdCourse)
- .HasConstraintName("teachers_courses_courses_fk");
- entity.HasOne(d => d.IdTeacherNavigation).WithMany(p => p.TeachersCourses)
- .HasForeignKey(d => d.IdTeacher)
- .HasConstraintName("teachers_courses_teachers_fk");
- });
- modelBuilder.Entity<User>(entity =>
- {
- entity.HasKey(e => e.IdUser).HasName("users_pk");
- entity.ToTable("users");
- entity.Property(e => e.IdUser)
- .UseIdentityAlwaysColumn()
- .HasColumnName("id_user");
- entity.Property(e => e.IdRole).HasColumnName("id_role");
- entity.Property(e => e.Login)
- .HasColumnType("character varying")
- .HasColumnName("login");
- entity.Property(e => e.Password)
- .HasColumnType("character varying")
- .HasColumnName("password");
- entity.HasOne(d => d.IdRoleNavigation).WithMany(p => p.Users)
- .HasForeignKey(d => d.IdRole)
- .HasConstraintName("users_fk");
- });
- modelBuilder.HasSequence("roles_id_role_seq").HasMax(2147483647L);
- modelBuilder.HasSequence("users_id_user_seq").HasMax(2147483647L);
- OnModelCreatingPartial(modelBuilder);
- }
- partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
- }
|