UpKrupinaContext.cs 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. using System;
  2. using System.Collections.Generic;
  3. using Microsoft.EntityFrameworkCore;
  4. namespace AvaloniaApplicationTest.Models;
  5. public partial class UpKrupinaContext : DbContext
  6. {
  7. public UpKrupinaContext()
  8. {
  9. }
  10. public UpKrupinaContext(DbContextOptions<UpKrupinaContext> 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<Tour> Tours { get; set; }
  19. public virtual DbSet<Type> Types { get; set; }
  20. protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
  21. #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.
  22. => optionsBuilder.UseNpgsql("Host=edu.pg.ngknn.local;Port=5432;Database=UP_Krupina;Username=43P;Password=444444");
  23. protected override void OnModelCreating(ModelBuilder modelBuilder)
  24. {
  25. modelBuilder.Entity<Country>(entity =>
  26. {
  27. entity.HasKey(e => e.Code).HasName("Country_pkey");
  28. entity.ToTable("Country");
  29. entity.Property(e => e.Code)
  30. .HasMaxLength(2)
  31. .IsFixedLength();
  32. entity.Property(e => e.Name).HasMaxLength(100);
  33. });
  34. modelBuilder.Entity<Hotel>(entity =>
  35. {
  36. entity.HasKey(e => e.Id).HasName("Hotel_pkey");
  37. entity.ToTable("Hotel");
  38. entity.Property(e => e.Id).ValueGeneratedNever();
  39. entity.Property(e => e.CountryCode)
  40. .HasMaxLength(2)
  41. .IsFixedLength();
  42. entity.Property(e => e.Name).HasMaxLength(100);
  43. entity.HasOne(d => d.CountryCodeNavigation).WithMany(p => p.Hotels)
  44. .HasForeignKey(d => d.CountryCode)
  45. .OnDelete(DeleteBehavior.ClientSetNull)
  46. .HasConstraintName("FK_Hotel_Country");
  47. entity.HasMany(d => d.Tours).WithMany(p => p.Hotels)
  48. .UsingEntity<Dictionary<string, object>>(
  49. "HotelOfTour",
  50. r => r.HasOne<Tour>().WithMany()
  51. .HasForeignKey("TourId")
  52. .OnDelete(DeleteBehavior.ClientSetNull)
  53. .HasConstraintName("FK_HotelOfTour_Tour"),
  54. l => l.HasOne<Hotel>().WithMany()
  55. .HasForeignKey("HotelId")
  56. .OnDelete(DeleteBehavior.ClientSetNull)
  57. .HasConstraintName("FK_HotelOfTour_Hotel"),
  58. j =>
  59. {
  60. j.HasKey("HotelId", "TourId").HasName("HotelOfTour_pkey");
  61. j.ToTable("HotelOfTour");
  62. });
  63. });
  64. modelBuilder.Entity<HotelComment>(entity =>
  65. {
  66. entity.HasKey(e => e.Id).HasName("HotelComment_pkey");
  67. entity.ToTable("HotelComment");
  68. entity.Property(e => e.Id).ValueGeneratedNever();
  69. entity.Property(e => e.Author).HasMaxLength(100);
  70. entity.Property(e => e.CreationDate).HasColumnType("timestamp(6) without time zone");
  71. entity.HasOne(d => d.Hotel).WithMany(p => p.HotelComments)
  72. .HasForeignKey(d => d.HotelId)
  73. .OnDelete(DeleteBehavior.ClientSetNull)
  74. .HasConstraintName("FK_HotelComment_Hotel");
  75. });
  76. modelBuilder.Entity<HotelImage>(entity =>
  77. {
  78. entity.HasKey(e => e.Id).HasName("HotelImage_pkey");
  79. entity.ToTable("HotelImage");
  80. entity.Property(e => e.Id).ValueGeneratedNever();
  81. entity.Property(e => e.ImageSource).HasColumnType("character varying");
  82. entity.HasOne(d => d.Hotel).WithMany(p => p.HotelImages)
  83. .HasForeignKey(d => d.HotelId)
  84. .OnDelete(DeleteBehavior.ClientSetNull)
  85. .HasConstraintName("FK_HotelImage_Hotel");
  86. });
  87. modelBuilder.Entity<Tour>(entity =>
  88. {
  89. entity.HasKey(e => e.Id).HasName("Tour_pkey");
  90. entity.ToTable("Tour");
  91. entity.Property(e => e.Id).ValueGeneratedNever();
  92. entity.Property(e => e.ImagePreview).HasColumnType("character varying");
  93. entity.Property(e => e.IsActual).HasColumnType("bit(1)");
  94. entity.Property(e => e.Name).HasMaxLength(100);
  95. entity.Property(e => e.Price).HasPrecision(19, 4);
  96. entity.HasMany(d => d.Types).WithMany(p => p.Tours)
  97. .UsingEntity<Dictionary<string, object>>(
  98. "TypeOfTour",
  99. r => r.HasOne<Type>().WithMany()
  100. .HasForeignKey("TypeId")
  101. .OnDelete(DeleteBehavior.ClientSetNull)
  102. .HasConstraintName("FK_TypeOfTour_Type"),
  103. l => l.HasOne<Tour>().WithMany()
  104. .HasForeignKey("TourId")
  105. .OnDelete(DeleteBehavior.ClientSetNull)
  106. .HasConstraintName("FK_TypeOfTour_Tour"),
  107. j =>
  108. {
  109. j.HasKey("TourId", "TypeId").HasName("TypeOfTour_pkey");
  110. j.ToTable("TypeOfTour");
  111. });
  112. });
  113. modelBuilder.Entity<Type>(entity =>
  114. {
  115. entity.HasKey(e => e.Id).HasName("Type_pkey");
  116. entity.ToTable("Type");
  117. entity.Property(e => e.Id).ValueGeneratedNever();
  118. entity.Property(e => e.Name).HasMaxLength(100);
  119. });
  120. modelBuilder.HasSequence("hotel_comment_id_seq").HasMax(2147483647L);
  121. modelBuilder.HasSequence("hotel_id_seq").HasMax(2147483647L);
  122. modelBuilder.HasSequence("hotel_of_tour_id_seq").HasMax(2147483647L);
  123. modelBuilder.HasSequence("tour_id_seq").HasMax(2147483647L);
  124. modelBuilder.HasSequence("type_id_seq").HasMax(2147483647L);
  125. modelBuilder.HasSequence("type_of_tour_id_seq").HasMax(2147483647L);
  126. OnModelCreatingPartial(modelBuilder);
  127. }
  128. partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
  129. }