Pavlov41pContext.cs 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. using System;
  2. using System.Collections.Generic;
  3. using Microsoft.EntityFrameworkCore;
  4. namespace AvaloniaPractic.Models;
  5. public partial class Pavlov41pContext : DbContext
  6. {
  7. public Pavlov41pContext()
  8. {
  9. }
  10. public Pavlov41pContext(DbContextOptions<Pavlov41pContext> options)
  11. : base(options)
  12. {
  13. }
  14. public virtual DbSet<Logined> Logineds { get; set; }
  15. public virtual DbSet<Role> Roles { get; set; }
  16. public virtual DbSet<User> Users { get; set; }
  17. protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
  18. #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.
  19. => optionsBuilder.UseNpgsql("Host=edu.pg.ngknn.local;Port=5432;Database=pavlov41p;Username=31P;Password=12345");
  20. protected override void OnModelCreating(ModelBuilder modelBuilder)
  21. {
  22. modelBuilder.Entity<Logined>(entity =>
  23. {
  24. entity.HasKey(e => e.Id).HasName("logined_pkey");
  25. entity.ToTable("logined");
  26. entity.Property(e => e.Id).HasColumnName("id");
  27. entity.Property(e => e.Login)
  28. .HasMaxLength(255)
  29. .HasColumnName("login");
  30. entity.Property(e => e.Password)
  31. .HasMaxLength(255)
  32. .HasColumnName("password");
  33. entity.Property(e => e.Roleid)
  34. .ValueGeneratedOnAdd()
  35. .HasColumnName("roleid");
  36. entity.Property(e => e.Userid)
  37. .ValueGeneratedOnAdd()
  38. .HasColumnName("userid");
  39. entity.HasOne(d => d.Role).WithMany(p => p.Logineds)
  40. .HasForeignKey(d => d.Roleid)
  41. .HasConstraintName("logined_roleid_fkey");
  42. entity.HasOne(d => d.User).WithMany(p => p.Logineds)
  43. .HasForeignKey(d => d.Userid)
  44. .HasConstraintName("logined_userid_fkey");
  45. });
  46. modelBuilder.Entity<Role>(entity =>
  47. {
  48. entity.HasKey(e => e.Id).HasName("role_pkey");
  49. entity.ToTable("role");
  50. entity.Property(e => e.Id).HasColumnName("id");
  51. entity.Property(e => e.Name)
  52. .HasMaxLength(50)
  53. .HasColumnName("name");
  54. });
  55. modelBuilder.Entity<User>(entity =>
  56. {
  57. entity.HasKey(e => e.Id).HasName("users_pkey");
  58. entity.ToTable("users");
  59. entity.Property(e => e.Id).HasColumnName("id");
  60. entity.Property(e => e.Createdat)
  61. .HasDefaultValueSql("CURRENT_TIMESTAMP")
  62. .HasColumnType("timestamp without time zone")
  63. .HasColumnName("createdat");
  64. entity.Property(e => e.Email)
  65. .HasMaxLength(255)
  66. .HasColumnName("email");
  67. entity.Property(e => e.Username)
  68. .HasMaxLength(100)
  69. .HasColumnName("username");
  70. });
  71. OnModelCreatingPartial(modelBuilder);
  72. }
  73. partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
  74. }