Bolshakov41pContext.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. using System;
  2. using System.Collections.Generic;
  3. using Microsoft.EntityFrameworkCore;
  4. namespace AvaloniaHomeTry.Models;
  5. public partial class Bolshakov41pContext : DbContext
  6. {
  7. public Bolshakov41pContext()
  8. {
  9. }
  10. public Bolshakov41pContext(DbContextOptions<Bolshakov41pContext> options)
  11. : base(options)
  12. {
  13. }
  14. public virtual DbSet<Gender> Genders { get; set; }
  15. public virtual DbSet<RolesTable> RolesTables { get; set; }
  16. public virtual DbSet<UsersTable> UsersTable { get; set; }
  17. protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
  18. #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.
  19. => optionsBuilder.UseNpgsql("Host=edu.pg.ngknn.local;Port=5432;Database=bolshakov41p;Username=31P;Password=12345");
  20. protected override void OnModelCreating(ModelBuilder modelBuilder)
  21. {
  22. modelBuilder.Entity<Gender>(entity =>
  23. {
  24. entity.HasKey(e => e.Id).HasName("genders_pkey");
  25. entity.ToTable("genders");
  26. entity.Property(e => e.Id).HasColumnName("id");
  27. entity.Property(e => e.GenderName)
  28. .HasMaxLength(7)
  29. .HasColumnName("genderName");
  30. });
  31. modelBuilder.Entity<RolesTable>(entity =>
  32. {
  33. entity.HasKey(e => e.Id).HasName("roles_table_pkey");
  34. entity.ToTable("roles_table");
  35. entity.Property(e => e.Id).HasColumnName("id");
  36. entity.Property(e => e.Role)
  37. .HasMaxLength(20)
  38. .HasColumnName("role");
  39. });
  40. modelBuilder.Entity<UsersTable>(entity =>
  41. {
  42. entity.HasKey(e => e.Id).HasName("users_table_pkey");
  43. entity.ToTable("users_table");
  44. entity.Property(e => e.Id).HasColumnName("id");
  45. entity.Property(e => e.Dataofbirth)
  46. .HasColumnType("timestamp without time zone")
  47. .HasColumnName("dataofbirth");
  48. entity.Property(e => e.Firstname)
  49. .HasMaxLength(30)
  50. .HasColumnName("firstname");
  51. entity.Property(e => e.IdGender).HasColumnName("genderid");
  52. entity.Property(e => e.Image).HasColumnName("image");
  53. entity.Property(e => e.Login)
  54. .HasMaxLength(30)
  55. .HasColumnName("login");
  56. entity.Property(e => e.Password)
  57. .HasMaxLength(30)
  58. .HasColumnName("password");
  59. entity.Property(e => e.Patronymic)
  60. .HasMaxLength(30)
  61. .HasColumnName("patronymic");
  62. entity.Property(e => e.IdRole).HasColumnName("roleid");
  63. entity.Property(e => e.Surname)
  64. .HasMaxLength(30)
  65. .HasColumnName("surname");
  66. entity.HasOne(d => d.GenderNavigation).WithMany(p => p.UsersTables)
  67. .HasForeignKey(d => d.IdGender)
  68. .HasConstraintName("users_table_genderid_fkey");
  69. entity.HasOne(d => d.RoleNavigation).WithMany(p => p.UsersTables)
  70. .HasForeignKey(d => d.IdRole)
  71. .HasConstraintName("users_table_roleid_fkey");
  72. });
  73. OnModelCreatingPartial(modelBuilder);
  74. }
  75. partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
  76. }