_41pShmelevMvContext.cs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. using System;
  2. using System.Collections.Generic;
  3. using Microsoft.EntityFrameworkCore;
  4. namespace AvaloniaApplicationTestNew.Models;
  5. public partial class _41pShmelevMvContext : DbContext
  6. {
  7. public _41pShmelevMvContext()
  8. {
  9. }
  10. public _41pShmelevMvContext(DbContextOptions<_41pShmelevMvContext> options)
  11. : base(options)
  12. {
  13. }
  14. public virtual DbSet<Gender> Genders { get; set; }
  15. public virtual DbSet<Logined> Logineds { get; set; }
  16. public virtual DbSet<Role> Roles { get; set; }
  17. public virtual DbSet<Trait> Traits { get; set; }
  18. public virtual DbSet<User> Users { get; set; }
  19. protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
  20. #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 https://go.microsoft.com/fwlink/?LinkId=723263.
  21. => optionsBuilder.UseNpgsql("Host=edu.pg.ngknn.local;Port=5432;Database=41P_ShmelevMV;Username=31P;Password=12345");
  22. protected override void OnModelCreating(ModelBuilder modelBuilder)
  23. {
  24. modelBuilder.Entity<Gender>(entity =>
  25. {
  26. entity.HasKey(e => e.IdGender).HasName("genders_pk");
  27. entity.ToTable("genders");
  28. entity.Property(e => e.IdGender).HasColumnName("id_gender");
  29. entity.Property(e => e.Gender1)
  30. .HasColumnType("character varying")
  31. .HasColumnName("gender");
  32. });
  33. modelBuilder.Entity<Logined>(entity =>
  34. {
  35. entity.HasKey(e => e.Id).HasName("logined_pk");
  36. entity.ToTable("logined");
  37. entity.HasIndex(e => e.IdRole, "IX_logined_id_role");
  38. entity.Property(e => e.Id).HasColumnName("id");
  39. entity.Property(e => e.IdRole).HasColumnName("id_role");
  40. entity.Property(e => e.Login)
  41. .HasColumnType("character varying")
  42. .HasColumnName("login");
  43. entity.Property(e => e.Password)
  44. .HasColumnType("character varying")
  45. .HasColumnName("password");
  46. entity.HasOne(d => d.IdRoleNavigation).WithMany(p => p.Logineds)
  47. .HasForeignKey(d => d.IdRole)
  48. .OnDelete(DeleteBehavior.Restrict)
  49. .HasConstraintName("logined_roles_fk");
  50. });
  51. modelBuilder.Entity<Role>(entity =>
  52. {
  53. entity.HasKey(e => e.IdRole).HasName("roles_pk");
  54. entity.ToTable("roles");
  55. entity.Property(e => e.IdRole).HasColumnName("id_role");
  56. entity.Property(e => e.RoleName)
  57. .HasColumnType("character varying")
  58. .HasColumnName("role_name");
  59. });
  60. modelBuilder.Entity<Trait>(entity =>
  61. {
  62. entity.HasKey(e => e.Idtrait).HasName("trait_pk");
  63. entity.ToTable("trait");
  64. entity.Property(e => e.Idtrait).HasColumnName("idtrait");
  65. entity.Property(e => e.Traitname)
  66. .HasColumnType("character varying")
  67. .HasColumnName("traitname");
  68. });
  69. modelBuilder.Entity<User>(entity =>
  70. {
  71. entity.HasKey(e => e.IdUser).HasName("users_pk");
  72. entity.ToTable("users");
  73. entity.HasIndex(e => e.IdGender, "IX_users_id_gender");
  74. entity.Property(e => e.IdUser)
  75. .ValueGeneratedNever()
  76. .HasColumnName("id_user");
  77. entity.Property(e => e.BirthDate)
  78. .HasColumnType("timestamp without time zone")
  79. .HasColumnName("birth_date");
  80. entity.Property(e => e.IdGender).HasColumnName("id_gender");
  81. entity.Property(e => e.Image).HasColumnName("image");
  82. entity.Property(e => e.Name)
  83. .HasColumnType("character varying")
  84. .HasColumnName("name");
  85. entity.HasOne(d => d.IdGenderNavigation).WithMany(p => p.Users)
  86. .HasForeignKey(d => d.IdGender)
  87. .OnDelete(DeleteBehavior.ClientSetNull)
  88. .HasConstraintName("users_genders_fk");
  89. entity.HasOne(d => d.IdUserNavigation).WithOne(p => p.User)
  90. .HasForeignKey<User>(d => d.IdUser)
  91. .HasConstraintName("users_logined_fk");
  92. entity.HasMany(d => d.IdTraits).WithMany(p => p.IdUsers)
  93. .UsingEntity<Dictionary<string, object>>(
  94. "UserTrait",
  95. r => r.HasOne<Trait>().WithMany()
  96. .HasForeignKey("IdTrait")
  97. .OnDelete(DeleteBehavior.ClientSetNull)
  98. .HasConstraintName("user_traits_trait_fk"),
  99. l => l.HasOne<User>().WithMany()
  100. .HasForeignKey("IdUser")
  101. .OnDelete(DeleteBehavior.Restrict)
  102. .HasConstraintName("user_traits_users_fk"),
  103. j =>
  104. {
  105. j.HasKey("IdUser", "IdTrait").HasName("user_traits_pk");
  106. j.ToTable("user_traits");
  107. j.IndexerProperty<int>("IdUser").HasColumnName("id_user");
  108. j.IndexerProperty<int>("IdTrait").HasColumnName("id_trait");
  109. });
  110. });
  111. OnModelCreatingPartial(modelBuilder);
  112. }
  113. partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
  114. }