using System; using System.Collections.Generic; using Microsoft.EntityFrameworkCore; namespace AvaloniaExample.Models; public partial class UsersContext : DbContext { public UsersContext() { } public UsersContext(DbContextOptions options) : base(options) { } public virtual DbSet Logins { get; set; } public virtual DbSet Subjects { get; set; } public virtual DbSet TeacherSubjects { get; set; } public virtual DbSet UsersInfos { 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=localhost;Port=5432;Database=Users;Username=postgres;Password=123"); protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder .HasPostgresEnum("genders", new[] { "мужчина", "женщина" }) .HasPostgresEnum("roles", new[] { "администратор", "преподаватель", "студент" }); modelBuilder.Entity(entity => { entity.HasKey(e => e.Id).HasName("logins_pkey"); entity.ToTable("logins"); entity.HasIndex(e => e.Value, "login_unique").IsUnique(); entity.Property(e => e.Id).HasColumnName("id"); entity.Property(e => e.Role).HasColumnName("role"); entity.Property(e => e.Value) .HasMaxLength(40) .HasColumnName("login"); entity.Property(e => e.Password) .HasMaxLength(40) .HasColumnName("password"); }); modelBuilder.Entity(entity => { entity.HasKey(e => e.Id).HasName("subjects_pkey"); entity.ToTable("subjects"); entity.Property(e => e.Id).HasColumnName("id"); entity.Property(e => e.Description) .HasMaxLength(300) .HasColumnName("description"); entity.Property(e => e.Name) .HasMaxLength(60) .HasColumnName("name"); }); modelBuilder.Entity(entity => { entity .HasNoKey() .ToTable("teacher_subject"); entity.Property(e => e.Login) .HasMaxLength(40) .HasColumnName("login"); entity.Property(e => e.Subject).HasColumnName("subject"); entity.HasOne(d => d.LoginNavigation).WithMany() .HasForeignKey(d => d.Login) .HasConstraintName("teacher_subject_login_fkey"); entity.HasOne(d => d.SubjectNavigation).WithMany() .HasForeignKey(d => d.Subject) .HasConstraintName("teacher_subject_subject_fkey"); }); modelBuilder.Entity(entity => { entity.HasKey(e => e.Login).HasName("users_info_pkey"); entity.ToTable("users_info"); entity.HasIndex(e => e.Mail, "users_info_mail_key").IsUnique(); entity.HasIndex(e => e.Phone, "users_info_phone_key").IsUnique(); entity.Property(e => e.Login) .HasMaxLength(40) .HasColumnName("login"); entity.Property(e => e.DateBirth).HasColumnName("date_birth"); entity.Property(e => e.Gender).HasColumnName("gender"); entity.Property(e => e.Mail) .HasMaxLength(60) .HasColumnName("mail"); entity.Property(e => e.Name) .HasMaxLength(200) .HasColumnName("name"); entity.Property(e => e.Phone) .HasMaxLength(20) .HasColumnName("phone"); entity.HasOne(d => d.LoginNavigation).WithOne(p => p.UsersInfo) .HasPrincipalKey(p => p.Value) .HasForeignKey(d => d.Login) .OnDelete(DeleteBehavior.ClientSetNull) .HasConstraintName("users_info_login_fkey"); }); OnModelCreatingPartial(modelBuilder); } partial void OnModelCreatingPartial(ModelBuilder modelBuilder); }