_1234Context.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. using System;
  2. using System.Collections.Generic;
  3. using Microsoft.EntityFrameworkCore;
  4. namespace AvaloniaApplication5.Models;
  5. public partial class _1234Context : DbContext
  6. {
  7. public _1234Context()
  8. {
  9. }
  10. public _1234Context(DbContextOptions<_1234Context> options)
  11. : base(options)
  12. {
  13. }
  14. public virtual DbSet<Gender> Genders { get; set; }
  15. public virtual DbSet<Logintable> Logintables { 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=1234;Username=41P;Password=12357");
  21. protected override void OnModelCreating(ModelBuilder modelBuilder)
  22. {
  23. modelBuilder.Entity<Gender>(entity =>
  24. {
  25. entity.HasKey(e => e.Id).HasName("genders_pk");
  26. entity.ToTable("genders");
  27. entity.Property(e => e.Id)
  28. .UseIdentityAlwaysColumn()
  29. .HasColumnName("id");
  30. entity.Property(e => e.Gender1)
  31. .HasColumnType("character varying")
  32. .HasColumnName("gender");
  33. });
  34. modelBuilder.Entity<Logintable>(entity =>
  35. {
  36. entity.HasKey(e => e.Id).HasName("logintable_pk");
  37. entity.ToTable("logintable");
  38. entity.Property(e => e.Id)
  39. .UseIdentityAlwaysColumn()
  40. .HasColumnName("id");
  41. entity.Property(e => e.IdRole).HasColumnName("id_role");
  42. entity.Property(e => e.Login)
  43. .HasColumnType("character varying")
  44. .HasColumnName("login");
  45. entity.Property(e => e.Password).HasColumnType("character varying");
  46. entity.HasOne(d => d.IdRoleNavigation).WithMany(p => p.Logintables)
  47. .HasForeignKey(d => d.IdRole)
  48. .OnDelete(DeleteBehavior.ClientSetNull)
  49. .HasConstraintName("logintable_fk");
  50. });
  51. modelBuilder.Entity<Role>(entity =>
  52. {
  53. entity.HasKey(e => e.Id).HasName("roles_pk");
  54. entity.ToTable("roles");
  55. entity.Property(e => e.Id).HasColumnName("id");
  56. entity.Property(e => e.Role1)
  57. .HasColumnType("character varying")
  58. .HasColumnName("role");
  59. });
  60. modelBuilder.Entity<User>(entity =>
  61. {
  62. entity.HasKey(e => e.IdLogin).HasName("users_pk");
  63. entity.ToTable("users");
  64. entity.Property(e => e.IdLogin)
  65. .ValueGeneratedNever()
  66. .HasColumnName("id_login");
  67. entity.Property(e => e.BirthDate)
  68. .HasColumnType("timestamp without time zone")
  69. .HasColumnName("birth_date");
  70. entity.Property(e => e.IdGender).HasColumnName("id_gender");
  71. entity.Property(e => e.Name)
  72. .HasColumnType("character varying")
  73. .HasColumnName("name");
  74. entity.HasOne(d => d.IdGenderNavigation).WithMany(p => p.Users)
  75. .HasForeignKey(d => d.IdGender)
  76. .OnDelete(DeleteBehavior.ClientSetNull)
  77. .HasConstraintName("users_fk_1");
  78. entity.HasOne(d => d.IdLoginNavigation).WithOne(p => p.User)
  79. .HasForeignKey<User>(d => d.IdLogin)
  80. .HasConstraintName("users_fk");
  81. });
  82. OnModelCreatingPartial(modelBuilder);
  83. }
  84. partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
  85. }