Bobarik41pContext.cs 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. using System;
  2. using System.Collections.Generic;
  3. using Microsoft.EntityFrameworkCore;
  4. namespace AvaloniaApplication1.Models;
  5. public partial class Bobarik41pContext : DbContext
  6. {
  7. public Bobarik41pContext()
  8. {
  9. }
  10. public Bobarik41pContext(DbContextOptions<Bobarik41pContext> options)
  11. : base(options)
  12. {
  13. }
  14. public virtual DbSet<Gender> Genders { get; set; }
  15. public virtual DbSet<Property> Properties { get; set; }
  16. public virtual DbSet<Role> Roles { get; set; }
  17. public virtual DbSet<Smeshariki> Smesharikis { get; set; }
  18. public virtual DbSet<User> Users { get; set; }
  19. protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
  20. #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.
  21. => optionsBuilder.UseNpgsql("Host=edu.pg.ngknn.local;Port=5432;Database=bobarik41p;Username=31P;Password=12345");
  22. protected override void OnModelCreating(ModelBuilder modelBuilder)
  23. {
  24. modelBuilder.Entity<Gender>(entity =>
  25. {
  26. entity.HasKey(e => e.Id).HasName("gender_pkey");
  27. entity.ToTable("gender");
  28. entity.Property(e => e.Id).HasColumnName("id");
  29. entity.Property(e => e.Title)
  30. .HasMaxLength(7)
  31. .HasColumnName("title");
  32. });
  33. modelBuilder.Entity<Property>(entity =>
  34. {
  35. entity.HasKey(e => e.Id).HasName("property_pkey");
  36. entity.ToTable("property");
  37. entity.Property(e => e.Id).HasColumnName("id");
  38. entity.Property(e => e.Title)
  39. .HasMaxLength(50)
  40. .HasColumnName("title");
  41. });
  42. modelBuilder.Entity<Role>(entity =>
  43. {
  44. entity.HasKey(e => e.Id).HasName("role_pkey");
  45. entity.ToTable("role");
  46. entity.Property(e => e.Id).HasColumnName("id");
  47. entity.Property(e => e.Title)
  48. .HasMaxLength(50)
  49. .HasColumnName("title");
  50. });
  51. modelBuilder.Entity<Smeshariki>(entity =>
  52. {
  53. entity.HasKey(e => e.Id).HasName("smeshariki_pkey");
  54. entity.ToTable("smeshariki");
  55. entity.Property(e => e.Id).HasColumnName("id");
  56. entity.Property(e => e.Age).HasColumnName("age");
  57. entity.Property(e => e.Animal)
  58. .HasMaxLength(50)
  59. .HasColumnName("animal");
  60. entity.Property(e => e.Gender).HasColumnName("gender");
  61. entity.Property(e => e.Image).HasColumnName("image");
  62. entity.Property(e => e.Name)
  63. .HasMaxLength(50)
  64. .HasColumnName("name");
  65. entity.HasOne(d => d.GenderNavigation).WithMany(p => p.Smesharikis)
  66. .HasForeignKey(d => d.Gender)
  67. .HasConstraintName("smeshariki_gender_fkey");
  68. entity.HasMany(d => d.IdProperties).WithMany(p => p.IdSmeshes)
  69. .UsingEntity<Dictionary<string, object>>(
  70. "SmeshProperty",
  71. r => r.HasOne<Property>().WithMany()
  72. .HasForeignKey("IdProperty")
  73. .OnDelete(DeleteBehavior.ClientSetNull)
  74. .HasConstraintName("smesh_property_id_property_fkey"),
  75. l => l.HasOne<Smeshariki>().WithMany()
  76. .HasForeignKey("IdSmesh")
  77. .OnDelete(DeleteBehavior.ClientSetNull)
  78. .HasConstraintName("smesh_property_id_smesh_fkey"),
  79. j =>
  80. {
  81. j.HasKey("IdSmesh", "IdProperty").HasName("smesh_property_pk");
  82. j.ToTable("smesh_property");
  83. j.IndexerProperty<int>("IdSmesh").HasColumnName("id_smesh");
  84. j.IndexerProperty<int>("IdProperty").HasColumnName("id_property");
  85. });
  86. });
  87. modelBuilder.Entity<User>(entity =>
  88. {
  89. entity.HasKey(e => e.Id).HasName("users_pkey");
  90. entity.ToTable("users");
  91. entity.HasIndex(e => e.Login, "users_login_key").IsUnique();
  92. entity.Property(e => e.Id).HasColumnName("id");
  93. entity.Property(e => e.DateOfBirth)
  94. .HasColumnType("timestamp without time zone")
  95. .HasColumnName("date_of_birth");
  96. entity.Property(e => e.FirstName)
  97. .HasMaxLength(50)
  98. .HasColumnName("first_name");
  99. entity.Property(e => e.Gender).HasColumnName("gender");
  100. entity.Property(e => e.IdRole).HasColumnName("id_role");
  101. entity.Property(e => e.LastName)
  102. .HasMaxLength(50)
  103. .HasColumnName("last_name");
  104. entity.Property(e => e.Login)
  105. .HasMaxLength(50)
  106. .HasColumnName("login");
  107. entity.Property(e => e.Password)
  108. .HasMaxLength(50)
  109. .HasColumnName("password");
  110. entity.Property(e => e.Patronymic)
  111. .HasMaxLength(50)
  112. .HasColumnName("patronymic");
  113. entity.HasOne(d => d.GenderNavigation).WithMany(p => p.Users)
  114. .HasForeignKey(d => d.Gender)
  115. .HasConstraintName("users_gender_fkey");
  116. entity.HasOne(d => d.IdRoleNavigation).WithMany(p => p.Users)
  117. .HasForeignKey(d => d.IdRole)
  118. .HasConstraintName("fk_roles_users");
  119. });
  120. OnModelCreatingPartial(modelBuilder);
  121. }
  122. partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
  123. }