123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- using System;
- using System.Collections.Generic;
- using Microsoft.EntityFrameworkCore;
- namespace AvaloniaApplicationTest.Models;
- public partial class UpKrupinaContext : DbContext
- {
- public UpKrupinaContext()
- {
- }
- public UpKrupinaContext(DbContextOptions<UpKrupinaContext> options)
- : base(options)
- {
- }
- public virtual DbSet<Country> Countries { get; set; }
- public virtual DbSet<Hotel> Hotels { get; set; }
- public virtual DbSet<HotelComment> HotelComments { get; set; }
- public virtual DbSet<HotelImage> HotelImages { get; set; }
- public virtual DbSet<Tour> Tours { get; set; }
- public virtual DbSet<Type> Types { get; set; }
- protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
- #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.
- => optionsBuilder.UseNpgsql("Host=edu.pg.ngknn.local;Port=5432;Database=UP_Krupina;Username=43P;Password=444444");
- protected override void OnModelCreating(ModelBuilder modelBuilder)
- {
- modelBuilder.Entity<Country>(entity =>
- {
- entity.HasKey(e => e.Code).HasName("Country_pkey");
- entity.ToTable("Country");
- entity.Property(e => e.Code)
- .HasMaxLength(2)
- .IsFixedLength();
- entity.Property(e => e.Name).HasMaxLength(100);
- });
- modelBuilder.Entity<Hotel>(entity =>
- {
- entity.HasKey(e => e.Id).HasName("Hotel_pkey");
- entity.ToTable("Hotel");
- entity.Property(e => e.Id).ValueGeneratedNever();
- entity.Property(e => e.CountryCode)
- .HasMaxLength(2)
- .IsFixedLength();
- entity.Property(e => e.Name).HasMaxLength(100);
- entity.HasOne(d => d.CountryCodeNavigation).WithMany(p => p.Hotels)
- .HasForeignKey(d => d.CountryCode)
- .OnDelete(DeleteBehavior.ClientSetNull)
- .HasConstraintName("FK_Hotel_Country");
- entity.HasMany(d => d.Tours).WithMany(p => p.Hotels)
- .UsingEntity<Dictionary<string, object>>(
- "HotelOfTour",
- r => r.HasOne<Tour>().WithMany()
- .HasForeignKey("TourId")
- .OnDelete(DeleteBehavior.ClientSetNull)
- .HasConstraintName("FK_HotelOfTour_Tour"),
- l => l.HasOne<Hotel>().WithMany()
- .HasForeignKey("HotelId")
- .OnDelete(DeleteBehavior.ClientSetNull)
- .HasConstraintName("FK_HotelOfTour_Hotel"),
- j =>
- {
- j.HasKey("HotelId", "TourId").HasName("HotelOfTour_pkey");
- j.ToTable("HotelOfTour");
- });
- });
- modelBuilder.Entity<HotelComment>(entity =>
- {
- entity.HasKey(e => e.Id).HasName("HotelComment_pkey");
- entity.ToTable("HotelComment");
- entity.Property(e => e.Id).ValueGeneratedNever();
- entity.Property(e => e.Author).HasMaxLength(100);
- entity.Property(e => e.CreationDate).HasColumnType("timestamp(6) without time zone");
- entity.HasOne(d => d.Hotel).WithMany(p => p.HotelComments)
- .HasForeignKey(d => d.HotelId)
- .OnDelete(DeleteBehavior.ClientSetNull)
- .HasConstraintName("FK_HotelComment_Hotel");
- });
- modelBuilder.Entity<HotelImage>(entity =>
- {
- entity.HasKey(e => e.Id).HasName("HotelImage_pkey");
- entity.ToTable("HotelImage");
- entity.Property(e => e.Id).ValueGeneratedNever();
- entity.Property(e => e.ImageSource).HasColumnType("character varying");
- entity.HasOne(d => d.Hotel).WithMany(p => p.HotelImages)
- .HasForeignKey(d => d.HotelId)
- .OnDelete(DeleteBehavior.ClientSetNull)
- .HasConstraintName("FK_HotelImage_Hotel");
- });
- modelBuilder.Entity<Tour>(entity =>
- {
- entity.HasKey(e => e.Id).HasName("Tour_pkey");
- entity.ToTable("Tour");
- entity.Property(e => e.Id).ValueGeneratedNever();
- entity.Property(e => e.ImagePreview).HasColumnType("character varying");
- entity.Property(e => e.IsActual).HasColumnType("bit(1)");
- entity.Property(e => e.Name).HasMaxLength(100);
- entity.Property(e => e.Price).HasPrecision(19, 4);
- entity.HasMany(d => d.Types).WithMany(p => p.Tours)
- .UsingEntity<Dictionary<string, object>>(
- "TypeOfTour",
- r => r.HasOne<Type>().WithMany()
- .HasForeignKey("TypeId")
- .OnDelete(DeleteBehavior.ClientSetNull)
- .HasConstraintName("FK_TypeOfTour_Type"),
- l => l.HasOne<Tour>().WithMany()
- .HasForeignKey("TourId")
- .OnDelete(DeleteBehavior.ClientSetNull)
- .HasConstraintName("FK_TypeOfTour_Tour"),
- j =>
- {
- j.HasKey("TourId", "TypeId").HasName("TypeOfTour_pkey");
- j.ToTable("TypeOfTour");
- });
- });
- modelBuilder.Entity<Type>(entity =>
- {
- entity.HasKey(e => e.Id).HasName("Type_pkey");
- entity.ToTable("Type");
- entity.Property(e => e.Id).ValueGeneratedNever();
- entity.Property(e => e.Name).HasMaxLength(100);
- });
- modelBuilder.HasSequence("hotel_comment_id_seq").HasMax(2147483647L);
- modelBuilder.HasSequence("hotel_id_seq").HasMax(2147483647L);
- modelBuilder.HasSequence("hotel_of_tour_id_seq").HasMax(2147483647L);
- modelBuilder.HasSequence("tour_id_seq").HasMax(2147483647L);
- modelBuilder.HasSequence("type_id_seq").HasMax(2147483647L);
- modelBuilder.HasSequence("type_of_tour_id_seq").HasMax(2147483647L);
- OnModelCreatingPartial(modelBuilder);
- }
- partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
- }
|