Bolshakov41pContext.cs 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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<Trait> Traits { get; set; }
  17. public virtual DbSet<UsersTable> UsersTable { get; set; }
  18. protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
  19. #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.
  20. => optionsBuilder.UseNpgsql("Host=edu.pg.ngknn.local;Port=5432;Database=bolshakov41p;Username=31P;Password=12345");
  21. protected override void OnModelCreating(ModelBuilder modelBuilder)
  22. {
  23. modelBuilder.Entity<Gender>(entity =>
  24. {
  25. entity.HasKey(e => e.Id).HasName("genders_pkey");
  26. entity.ToTable("genders");
  27. entity.Property(e => e.Id).HasColumnName("id");
  28. entity.Property(e => e.GenderName)
  29. .HasMaxLength(7)
  30. .HasColumnName("genderName");
  31. });
  32. modelBuilder.Entity<RolesTable>(entity =>
  33. {
  34. entity.HasKey(e => e.Id).HasName("roles_table_pkey");
  35. entity.ToTable("roles_table");
  36. entity.Property(e => e.Id).HasColumnName("id");
  37. entity.Property(e => e.Role)
  38. .HasMaxLength(20)
  39. .HasColumnName("role");
  40. });
  41. modelBuilder.Entity<Trait>(entity =>
  42. {
  43. entity.HasKey(e => e.Idtraits).HasName("traits_pkey");
  44. entity.ToTable("traits");
  45. entity.Property(e => e.Idtraits).HasColumnName("idtraits");
  46. entity.Property(e => e.Titletraits).HasColumnName("titletraits");
  47. });
  48. modelBuilder.Entity<UsersTable>(entity =>
  49. {
  50. entity.HasKey(e => e.Id).HasName("users_table_pkey");
  51. entity.ToTable("users_table");
  52. entity.Property(e => e.Id).HasColumnName("id");
  53. entity.Property(e => e.Dataofbirth)
  54. .HasColumnType("timestamp without time zone")
  55. .HasColumnName("dataofbirth");
  56. entity.Property(e => e.Firstname)
  57. .HasMaxLength(30)
  58. .HasColumnName("firstname");
  59. entity.Property(e => e.IdGender).HasColumnName("genderid");
  60. entity.Property(e => e.Image).HasColumnName("image");
  61. entity.Property(e => e.Login)
  62. .HasMaxLength(30)
  63. .HasColumnName("login");
  64. entity.Property(e => e.Password)
  65. .HasMaxLength(30)
  66. .HasColumnName("password");
  67. entity.Property(e => e.Patronymic)
  68. .HasMaxLength(30)
  69. .HasColumnName("patronymic");
  70. entity.Property(e => e.IdRole).HasColumnName("roleid");
  71. entity.Property(e => e.Surname)
  72. .HasMaxLength(30)
  73. .HasColumnName("surname");
  74. entity.HasOne(d => d.GenderNavigation).WithMany(p => p.UsersTables)
  75. .HasForeignKey(d => d.IdGender)
  76. .HasConstraintName("users_table_genderid_fkey");
  77. entity.HasOne(d => d.RoleNavigation).WithMany(p => p.UsersTables)
  78. .HasForeignKey(d => d.IdRole)
  79. .HasConstraintName("users_table_roleid_fkey");
  80. entity.HasMany(d => d.IdTraits).WithMany(p => p.Idusers)
  81. .UsingEntity<Dictionary<string, object>>(
  82. "Usersandtrait",
  83. r => r.HasOne<Trait>().WithMany()
  84. .HasForeignKey("Idtraits")
  85. .OnDelete(DeleteBehavior.ClientSetNull)
  86. .HasConstraintName("usersandtraits_idtraits_fkey"),
  87. l => l.HasOne<UsersTable>().WithMany()
  88. .HasForeignKey("Iduser")
  89. .OnDelete(DeleteBehavior.ClientSetNull)
  90. .HasConstraintName("usersandtraits_iduser_fkey"),
  91. j =>
  92. {
  93. j.HasKey("Iduser", "Idtraits").HasName("usersandtraits_pkey");
  94. j.ToTable("usersandtraits");
  95. j.IndexerProperty<int>("Iduser").HasColumnName("iduser");
  96. j.IndexerProperty<int>("Idtraits").HasColumnName("idtraits");
  97. });
  98. });
  99. OnModelCreatingPartial(modelBuilder);
  100. }
  101. partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
  102. }