_43pGaruaev2Context.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. using System;
  2. using System.Collections.Generic;
  3. using Microsoft.EntityFrameworkCore;
  4. namespace Users_Roles.Models;
  5. public partial class _43pGaruaev2Context : DbContext
  6. {
  7. public _43pGaruaev2Context()
  8. {
  9. }
  10. public _43pGaruaev2Context(DbContextOptions<_43pGaruaev2Context> options)
  11. : base(options)
  12. {
  13. }
  14. public virtual DbSet<Role> Roles { get; set; }
  15. public virtual DbSet<User> Users { get; set; }
  16. protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
  17. #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.
  18. => optionsBuilder.UseNpgsql("Host=edu.pg.ngknn.local;Port=5432;Database=43P_Garuaev2;Username=43P;Password=444444");
  19. protected override void OnModelCreating(ModelBuilder modelBuilder)
  20. {
  21. modelBuilder.Entity<Role>(entity =>
  22. {
  23. entity.HasKey(e => e.IdRole).HasName("roles_pkey");
  24. entity.ToTable("roles");
  25. entity.Property(e => e.IdRole).HasColumnName("id_role");
  26. entity.Property(e => e.Title)
  27. .HasColumnType("character varying")
  28. .HasColumnName("title");
  29. });
  30. modelBuilder.Entity<User>(entity =>
  31. {
  32. entity.HasKey(e => e.IdUser).HasName("users_pkey");
  33. entity.ToTable("users");
  34. entity.Property(e => e.IdUser).HasColumnName("id_user");
  35. entity.Property(e => e.Fio)
  36. .HasColumnType("character varying")
  37. .HasColumnName("fio");
  38. entity.Property(e => e.Image).HasColumnName("image");
  39. entity.Property(e => e.Login)
  40. .HasColumnType("character varying")
  41. .HasColumnName("login");
  42. entity.Property(e => e.Pasword).HasColumnName("pasword");
  43. entity.Property(e => e.RoleUser).HasColumnName("role_user");
  44. entity.HasOne(d => d.RoleUserNavigation).WithMany(p => p.Users)
  45. .HasForeignKey(d => d.RoleUser)
  46. .HasConstraintName("users_role_user_fkey");
  47. });
  48. OnModelCreatingPartial(modelBuilder);
  49. }
  50. partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
  51. }