UP_SmirnovContext.cs 8.7 KB

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