Gr692KnsContext.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. using System;
  2. using System.Collections.Generic;
  3. using Microsoft.EntityFrameworkCore;
  4. namespace QualTask.Models;
  5. public partial class Gr692KnsContext : DbContext
  6. {
  7. public Gr692KnsContext()
  8. {
  9. }
  10. public Gr692KnsContext(DbContextOptions<Gr692KnsContext> 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 http://go.microsoft.com/fwlink/?LinkId=723263.
  18. => optionsBuilder.UseNpgsql("Host=10.30.0.137;Port=5432;Database=gr692_kns;Username=gr692_kns;Password=pap04kA?");
  19. protected override void OnModelCreating(ModelBuilder modelBuilder)
  20. {
  21. modelBuilder.Entity<Role>(entity =>
  22. {
  23. entity.HasKey(e => e.Id).HasName("roles_pkey");
  24. entity.ToTable("roles");
  25. entity.Property(e => e.Id).HasColumnName("id");
  26. entity.Property(e => e.RoleName)
  27. .HasMaxLength(50)
  28. .HasColumnName("role_name");
  29. });
  30. modelBuilder.Entity<User>(entity =>
  31. {
  32. entity.HasKey(e => e.Id).HasName("users_pkey");
  33. entity.ToTable("users");
  34. entity.Property(e => e.Id).HasColumnName("id");
  35. entity.Property(e => e.Fname)
  36. .HasMaxLength(100)
  37. .HasColumnName("fname");
  38. entity.Property(e => e.Lname)
  39. .HasMaxLength(100)
  40. .HasColumnName("lname");
  41. entity.Property(e => e.Login)
  42. .HasMaxLength(100)
  43. .HasColumnName("login");
  44. entity.Property(e => e.Password)
  45. .HasMaxLength(100)
  46. .HasColumnName("password");
  47. entity.Property(e => e.Role).HasColumnName("role");
  48. entity.HasOne(d => d.RoleNavigation).WithMany(p => p.Users)
  49. .HasForeignKey(d => d.Role)
  50. .OnDelete(DeleteBehavior.ClientSetNull)
  51. .HasConstraintName("users_role_fkey");
  52. });
  53. OnModelCreatingPartial(modelBuilder);
  54. }
  55. partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
  56. }