UserBaseContext.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. using System;
  2. using System.Collections.Generic;
  3. using Microsoft.EntityFrameworkCore;
  4. namespace AvaloniaApplicationPersonalPage.Models;
  5. public partial class UserBaseContext : DbContext
  6. {
  7. public UserBaseContext()
  8. {
  9. }
  10. public UserBaseContext(DbContextOptions<UserBaseContext> options)
  11. : base(options)
  12. {
  13. }
  14. public virtual DbSet<GenderTable> GenderTables { get; set; }
  15. public virtual DbSet<LoginTable> LoginTables { get; set; }
  16. public virtual DbSet<RoleTable> RoleTables { get; set; }
  17. public virtual DbSet<UserTable> UserTables { 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=UserBase;Username=43P;Password=444444");
  21. protected override void OnModelCreating(ModelBuilder modelBuilder)
  22. {
  23. modelBuilder.Entity<GenderTable>(entity =>
  24. {
  25. entity.HasKey(e => e.IdGender).HasName("gender_table_pk");
  26. entity.ToTable("gender_table");
  27. entity.Property(e => e.IdGender).HasColumnName("id_gender");
  28. entity.Property(e => e.Gender)
  29. .HasColumnType("character varying")
  30. .HasColumnName("gender");
  31. });
  32. modelBuilder.Entity<LoginTable>(entity =>
  33. {
  34. entity.HasKey(e => e.IdLogin).HasName("login_table_pk");
  35. entity.ToTable("login_table");
  36. entity.Property(e => e.IdLogin).HasColumnName("id_login");
  37. entity.Property(e => e.IdRole).HasColumnName("id_role");
  38. entity.Property(e => e.Login)
  39. .HasColumnType("character varying")
  40. .HasColumnName("login");
  41. entity.Property(e => e.Password)
  42. .HasColumnType("character varying")
  43. .HasColumnName("password");
  44. entity.HasOne(d => d.IdRoleNavigation).WithMany(p => p.LoginTables)
  45. .HasForeignKey(d => d.IdRole)
  46. .OnDelete(DeleteBehavior.ClientSetNull)
  47. .HasConstraintName("login_table_fk");
  48. });
  49. modelBuilder.Entity<RoleTable>(entity =>
  50. {
  51. entity.HasKey(e => e.IdRole).HasName("role_table_pk");
  52. entity.ToTable("role_table");
  53. entity.Property(e => e.IdRole).HasColumnName("id_role");
  54. entity.Property(e => e.Role)
  55. .HasColumnType("character varying")
  56. .HasColumnName("role");
  57. });
  58. modelBuilder.Entity<UserTable>(entity =>
  59. {
  60. entity.HasKey(e => e.IdUser).HasName("user_table_pk");
  61. entity.ToTable("user_table");
  62. entity.Property(e => e.IdUser)
  63. .ValueGeneratedNever()
  64. .HasColumnName("id_user");
  65. entity.Property(e => e.Date)
  66. .HasColumnType("timestamp without time zone")
  67. .HasColumnName("date");
  68. entity.Property(e => e.IdGender).HasColumnName("id_gender");
  69. entity.Property(e => e.Name)
  70. .HasColumnType("character varying")
  71. .HasColumnName("name");
  72. entity.HasOne(d => d.IdGenderNavigation).WithMany(p => p.UserTables)
  73. .HasForeignKey(d => d.IdGender)
  74. .OnDelete(DeleteBehavior.ClientSetNull)
  75. .HasConstraintName("user_table_fk");
  76. entity.HasOne(d => d.IdUserNavigation).WithOne(p => p.UserTable)
  77. .HasForeignKey<UserTable>(d => d.IdUser)
  78. .HasConstraintName("user_table_fk_1");
  79. });
  80. OnModelCreatingPartial(modelBuilder);
  81. }
  82. partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
  83. }