UpPrytovContext.cs 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. using System;
  2. using System.Collections.Generic;
  3. using Microsoft.EntityFrameworkCore;
  4. namespace UPtur.Models;
  5. public partial class UpPrytovContext : DbContext
  6. {
  7. public UpPrytovContext()
  8. {
  9. }
  10. public UpPrytovContext(DbContextOptions<UpPrytovContext> options)
  11. : base(options)
  12. {
  13. }
  14. public virtual DbSet<Country> Countries { get; set; }
  15. public virtual DbSet<Hotel> Hotels { get; set; }
  16. public virtual DbSet<HotelComment> HotelComments { get; set; }
  17. public virtual DbSet<HotelImage> HotelImages { get; set; }
  18. public virtual DbSet<HotelOfTour> HotelOfTours { get; set; }
  19. public virtual DbSet<Tour> Tours { get; set; }
  20. public virtual DbSet<Type> Types { get; set; }
  21. public virtual DbSet<TypeOfTour> TypeOfTours { get; set; }
  22. protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
  23. #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.
  24. => optionsBuilder.UseNpgsql("Host=edu.pg.ngknn.local;Port=5432;Database=UP_Prytov;Username=43P;Password=444444");
  25. protected override void OnModelCreating(ModelBuilder modelBuilder)
  26. {
  27. modelBuilder.Entity<Country>(entity =>
  28. {
  29. entity.HasKey(e => e.Code).HasName("country_pk");
  30. entity.ToTable("country");
  31. entity.Property(e => e.Code)
  32. .HasMaxLength(2)
  33. .IsFixedLength()
  34. .HasColumnName("code");
  35. entity.Property(e => e.Name)
  36. .HasColumnType("character varying")
  37. .HasColumnName("name");
  38. });
  39. modelBuilder.Entity<Hotel>(entity =>
  40. {
  41. entity.HasKey(e => e.Id).HasName("hotel_pk");
  42. entity.ToTable("hotel");
  43. entity.Property(e => e.Id)
  44. .UseIdentityAlwaysColumn()
  45. .HasColumnName("id");
  46. entity.Property(e => e.CountOfStars).HasColumnName("count_of_stars");
  47. entity.Property(e => e.CountryCode)
  48. .HasMaxLength(2)
  49. .IsFixedLength()
  50. .HasColumnName("country_code");
  51. entity.Property(e => e.Description)
  52. .HasColumnType("character varying")
  53. .HasColumnName("description");
  54. entity.Property(e => e.Name)
  55. .HasColumnType("character varying")
  56. .HasColumnName("name");
  57. entity.HasOne(d => d.CountryCodeNavigation).WithMany(p => p.Hotels)
  58. .HasForeignKey(d => d.CountryCode)
  59. .OnDelete(DeleteBehavior.ClientSetNull)
  60. .HasConstraintName("hotel_country_fk");
  61. });
  62. modelBuilder.Entity<HotelComment>(entity =>
  63. {
  64. entity.HasKey(e => e.Id).HasName("hotel_comment_pk");
  65. entity.ToTable("hotel_comment");
  66. entity.Property(e => e.Id)
  67. .UseIdentityAlwaysColumn()
  68. .HasColumnName("id");
  69. entity.Property(e => e.Author)
  70. .HasColumnType("character varying")
  71. .HasColumnName("author");
  72. entity.Property(e => e.CreationDate).HasColumnName("creation_date");
  73. entity.Property(e => e.HotelId).HasColumnName("hotel_id");
  74. entity.Property(e => e.Text)
  75. .HasColumnType("character varying")
  76. .HasColumnName("text");
  77. entity.HasOne(d => d.Hotel).WithMany(p => p.HotelComments)
  78. .HasForeignKey(d => d.HotelId)
  79. .OnDelete(DeleteBehavior.ClientSetNull)
  80. .HasConstraintName("hotel_comment_hotel_fk");
  81. });
  82. modelBuilder.Entity<HotelImage>(entity =>
  83. {
  84. entity.HasKey(e => e.Id).HasName("hotel_image_pk");
  85. entity.ToTable("hotel_image");
  86. entity.Property(e => e.Id)
  87. .ValueGeneratedNever()
  88. .HasColumnName("id");
  89. entity.Property(e => e.HotelId).HasColumnName("hotel_id");
  90. entity.Property(e => e.ImageSource).HasColumnName("image_source");
  91. entity.HasOne(d => d.Hotel).WithMany(p => p.HotelImages)
  92. .HasForeignKey(d => d.HotelId)
  93. .OnDelete(DeleteBehavior.ClientSetNull)
  94. .HasConstraintName("hotel_image_hotel_fk");
  95. });
  96. modelBuilder.Entity<HotelOfTour>(entity =>
  97. {
  98. entity.HasKey(e => e.Id).HasName("hotel_of_tour_pk");
  99. entity.ToTable("hotel_of_tour");
  100. entity.Property(e => e.Id)
  101. .UseIdentityAlwaysColumn()
  102. .HasColumnName("id");
  103. entity.Property(e => e.HotelId).HasColumnName("hotel_id");
  104. entity.Property(e => e.TourId).HasColumnName("tour_id");
  105. entity.HasOne(d => d.Hotel).WithMany(p => p.HotelOfTours)
  106. .HasForeignKey(d => d.HotelId)
  107. .OnDelete(DeleteBehavior.ClientSetNull)
  108. .HasConstraintName("hotel_of_tour_hotel_fk");
  109. entity.HasOne(d => d.Tour).WithMany(p => p.HotelOfTours)
  110. .HasForeignKey(d => d.TourId)
  111. .OnDelete(DeleteBehavior.ClientSetNull)
  112. .HasConstraintName("hotel_of_tour_tour_fk");
  113. });
  114. modelBuilder.Entity<Tour>(entity =>
  115. {
  116. entity.HasKey(e => e.Id).HasName("tour_pk");
  117. entity.ToTable("tour");
  118. entity.Property(e => e.Id)
  119. .UseIdentityAlwaysColumn()
  120. .HasColumnName("id");
  121. entity.Property(e => e.Desription)
  122. .HasColumnType("character varying")
  123. .HasColumnName("desription");
  124. entity.Property(e => e.ImagePreview).HasColumnName("image_preview");
  125. entity.Property(e => e.IsActual)
  126. .HasColumnType("bit(1)")
  127. .HasColumnName("is_actual");
  128. entity.Property(e => e.Name)
  129. .HasColumnType("character varying")
  130. .HasColumnName("name");
  131. entity.Property(e => e.Price)
  132. .HasColumnType("money")
  133. .HasColumnName("price");
  134. entity.Property(e => e.TicketCount).HasColumnName("ticket_count");
  135. });
  136. modelBuilder.Entity<Type>(entity =>
  137. {
  138. entity.HasKey(e => e.Id).HasName("type_pk");
  139. entity.ToTable("type");
  140. entity.Property(e => e.Id)
  141. .UseIdentityAlwaysColumn()
  142. .HasColumnName("id");
  143. entity.Property(e => e.Description)
  144. .HasColumnType("character varying")
  145. .HasColumnName("description");
  146. entity.Property(e => e.Name)
  147. .HasColumnType("character varying")
  148. .HasColumnName("name");
  149. });
  150. modelBuilder.Entity<TypeOfTour>(entity =>
  151. {
  152. entity.HasKey(e => e.Id).HasName("type_of_tour_pk");
  153. entity.ToTable("type_of_tour");
  154. entity.Property(e => e.Id)
  155. .UseIdentityAlwaysColumn()
  156. .HasColumnName("id");
  157. entity.Property(e => e.TourId).HasColumnName("tour_id");
  158. entity.Property(e => e.TypeId).HasColumnName("type_id");
  159. entity.HasOne(d => d.Tour).WithMany(p => p.TypeOfTours)
  160. .HasForeignKey(d => d.TourId)
  161. .OnDelete(DeleteBehavior.ClientSetNull)
  162. .HasConstraintName("type_of_tour_tour_fk");
  163. entity.HasOne(d => d.Type).WithMany(p => p.TypeOfTours)
  164. .HasForeignKey(d => d.TypeId)
  165. .OnDelete(DeleteBehavior.ClientSetNull)
  166. .HasConstraintName("type_of_tour_type_fk");
  167. });
  168. modelBuilder.HasSequence("hotel_comment_id_seq").HasMax(2147483647L);
  169. modelBuilder.HasSequence("hotel_comment_id_seq1").HasMax(2147483647L);
  170. modelBuilder.HasSequence("hotel_id_seq").HasMax(2147483647L);
  171. modelBuilder.HasSequence("hotel_id_seq1").HasMax(2147483647L);
  172. modelBuilder.HasSequence("hotel_of_tour_id_seq").HasMax(2147483647L);
  173. modelBuilder.HasSequence("hotel_of_tour_id_seq1").HasMax(2147483647L);
  174. modelBuilder.HasSequence("tour_id_seq").HasMax(2147483647L);
  175. modelBuilder.HasSequence("tour_id_seq1").HasMax(2147483647L);
  176. modelBuilder.HasSequence("type_id_seq").HasMax(2147483647L);
  177. modelBuilder.HasSequence("type_id_seq1").HasMax(2147483647L);
  178. modelBuilder.HasSequence("type_of_tour_id_seq").HasMax(2147483647L);
  179. modelBuilder.HasSequence("type_of_tour_id_seq1").HasMax(2147483647L);
  180. OnModelCreatingPartial(modelBuilder);
  181. }
  182. partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
  183. }