Galochkin41pContext.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. using System;
  2. using System.Collections.Generic;
  3. using Microsoft.EntityFrameworkCore;
  4. namespace reactivepril.Models;
  5. public partial class Galochkin41pContext : DbContext
  6. {
  7. public Galochkin41pContext()
  8. {
  9. }
  10. public Galochkin41pContext(DbContextOptions<Galochkin41pContext> options)
  11. : base(options)
  12. {
  13. }
  14. public virtual DbSet<Gender> Genders { get; set; }
  15. public virtual DbSet<Image> Images { get; set; }
  16. public virtual DbSet<Role> Roles { get; set; }
  17. public virtual DbSet<User> Users { 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=galochkin41p;Username=31P;Password=12345");
  21. protected override void OnModelCreating(ModelBuilder modelBuilder)
  22. {
  23. modelBuilder.Entity<Gender>(entity =>
  24. {
  25. entity.HasKey(e => e.IdGender).HasName("gender_pkey");
  26. entity.ToTable("gender");
  27. entity.Property(e => e.IdGender).HasColumnName("id_gender");
  28. entity.Property(e => e.NameGender)
  29. .HasMaxLength(10)
  30. .HasColumnName("name_gender");
  31. });
  32. modelBuilder.Entity<Image>(entity =>
  33. {
  34. entity.HasKey(e => e.Id).HasName("images_pkey");
  35. entity.ToTable("images");
  36. entity.Property(e => e.Id).HasColumnName("id");
  37. entity.Property(e => e.Image1).HasColumnName("image");
  38. entity.Property(e => e.Users).HasColumnName("users");
  39. entity.HasOne(d => d.UsersNavigation).WithMany(p => p.Images)
  40. .HasForeignKey(d => d.Users)
  41. .HasConstraintName("images_users_fkey");
  42. });
  43. modelBuilder.Entity<Role>(entity =>
  44. {
  45. entity.HasKey(e => e.IdRole).HasName("roles_pkey");
  46. entity.ToTable("roles");
  47. entity.Property(e => e.IdRole)
  48. .ValueGeneratedNever()
  49. .HasColumnName("id_role");
  50. entity.Property(e => e.Names)
  51. .HasMaxLength(15)
  52. .HasColumnName("names");
  53. });
  54. modelBuilder.Entity<User>(entity =>
  55. {
  56. entity.HasKey(e => e.UserId).HasName("users_pkey");
  57. entity.ToTable("users");
  58. entity.Property(e => e.UserId).HasColumnName("user_id");
  59. entity.Property(e => e.Genders).HasColumnName("genders");
  60. entity.Property(e => e.Login)
  61. .HasMaxLength(50)
  62. .HasColumnName("login");
  63. entity.Property(e => e.Name)
  64. .HasMaxLength(20)
  65. .HasColumnName("name");
  66. entity.Property(e => e.Password)
  67. .HasMaxLength(50)
  68. .HasColumnName("password");
  69. entity.Property(e => e.Roles).HasColumnName("roles");
  70. entity.Property(e => e.Surname)
  71. .HasMaxLength(20)
  72. .HasColumnName("surname");
  73. entity.HasOne(d => d.GendersNavigation).WithMany(p => p.Users)
  74. .HasForeignKey(d => d.Genders)
  75. .HasConstraintName("users_genders_fkey");
  76. entity.HasOne(d => d.RolesNavigation).WithMany(p => p.Users)
  77. .HasForeignKey(d => d.Roles)
  78. .HasConstraintName("users_roles_fkey");
  79. });
  80. OnModelCreatingPartial(modelBuilder);
  81. }
  82. partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
  83. }