189 lines
6.7 KiB
C#
189 lines
6.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace Subd;
|
|
|
|
public partial class Onlinecinema2Context : DbContext
|
|
{
|
|
public Onlinecinema2Context()
|
|
{
|
|
}
|
|
|
|
public Onlinecinema2Context(DbContextOptions<Onlinecinema2Context> options)
|
|
: base(options)
|
|
{
|
|
}
|
|
|
|
public virtual DbSet<CountryView> CountryViews { get; set; }
|
|
|
|
public virtual DbSet<Director> Directors { get; set; }
|
|
|
|
public virtual DbSet<Film> Films { get; set; }
|
|
|
|
public virtual DbSet<ParentCompany> ParentCompanies { get; set; }
|
|
|
|
public virtual DbSet<Studio> Studios { get; set; }
|
|
|
|
public virtual DbSet<UsaView> UsaViews { get; set; }
|
|
|
|
public virtual DbSet<User> Users { get; set; }
|
|
|
|
public virtual DbSet<UserRating> UserRatings { 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=localhost;Port=5432;Database=onlinecinema2;Username=postgres;Password=12345");
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
{
|
|
modelBuilder.Entity<CountryView>(entity =>
|
|
{
|
|
entity
|
|
.HasNoKey()
|
|
.ToView("country_view");
|
|
|
|
entity.Property(e => e.Country)
|
|
.HasMaxLength(50)
|
|
.HasColumnName("country");
|
|
entity.Property(e => e.Date).HasColumnName("date");
|
|
entity.Property(e => e.Name)
|
|
.HasMaxLength(50)
|
|
.HasColumnName("name");
|
|
});
|
|
|
|
modelBuilder.Entity<Director>(entity =>
|
|
{
|
|
entity.HasKey(e => e.IdDirector).HasName("director_pkey");
|
|
|
|
entity.ToTable("director");
|
|
|
|
entity.Property(e => e.IdDirector).HasColumnName("id_director");
|
|
entity.Property(e => e.Country)
|
|
.HasMaxLength(50)
|
|
.HasColumnName("country");
|
|
entity.Property(e => e.Date).HasColumnName("date");
|
|
entity.Property(e => e.Name)
|
|
.HasMaxLength(50)
|
|
.HasColumnName("name");
|
|
});
|
|
|
|
modelBuilder.Entity<Film>(entity =>
|
|
{
|
|
entity.HasKey(e => e.IdFilm).HasName("films_pkey");
|
|
|
|
entity.ToTable("films");
|
|
|
|
entity.Property(e => e.IdFilm).HasColumnName("id_film");
|
|
entity.Property(e => e.CoastBuy).HasColumnName("coast_buy");
|
|
entity.Property(e => e.CoastRenta).HasColumnName("coast_renta");
|
|
entity.Property(e => e.Country)
|
|
.HasMaxLength(50)
|
|
.HasColumnName("country");
|
|
entity.Property(e => e.Genre)
|
|
.HasMaxLength(50)
|
|
.HasColumnName("genre");
|
|
entity.Property(e => e.IdDirector).HasColumnName("id_director");
|
|
entity.Property(e => e.IdStudio).HasColumnName("id_studio");
|
|
entity.Property(e => e.NameFilm)
|
|
.HasMaxLength(50)
|
|
.HasColumnName("name_film");
|
|
|
|
entity.HasOne(d => d.IdDirectorNavigation).WithMany(p => p.Films)
|
|
.HasForeignKey(d => d.IdDirector)
|
|
.HasConstraintName("films_id_director_fkey");
|
|
|
|
entity.HasOne(d => d.IdStudioNavigation).WithMany(p => p.Films)
|
|
.HasForeignKey(d => d.IdStudio)
|
|
.HasConstraintName("films_id_studio_fkey");
|
|
});
|
|
|
|
modelBuilder.Entity<ParentCompany>(entity =>
|
|
{
|
|
entity.HasKey(e => e.IdParentCompany).HasName("parent_company_pkey");
|
|
|
|
entity.ToTable("parent_company");
|
|
|
|
entity.Property(e => e.IdParentCompany).HasColumnName("id_parent_company");
|
|
entity.Property(e => e.Country)
|
|
.HasMaxLength(50)
|
|
.HasColumnName("country");
|
|
entity.Property(e => e.Date).HasColumnName("date");
|
|
entity.Property(e => e.Name)
|
|
.HasMaxLength(50)
|
|
.HasColumnName("name");
|
|
});
|
|
|
|
modelBuilder.Entity<Studio>(entity =>
|
|
{
|
|
entity.HasKey(e => e.IdStudio).HasName("studio_pkey");
|
|
|
|
entity.ToTable("studio");
|
|
|
|
entity.Property(e => e.IdStudio).HasColumnName("id_studio");
|
|
entity.Property(e => e.Country)
|
|
.HasMaxLength(50)
|
|
.HasColumnName("country");
|
|
entity.Property(e => e.Date).HasColumnName("date");
|
|
entity.Property(e => e.IdParentCompany).HasColumnName("id_parent_company");
|
|
entity.Property(e => e.Name)
|
|
.HasMaxLength(50)
|
|
.HasColumnName("name");
|
|
|
|
entity.HasOne(d => d.IdParentCompanyNavigation).WithMany(p => p.Studios)
|
|
.HasForeignKey(d => d.IdParentCompany)
|
|
.HasConstraintName("studio_id_parent_company_fkey");
|
|
});
|
|
|
|
modelBuilder.Entity<UsaView>(entity =>
|
|
{
|
|
entity
|
|
.HasNoKey()
|
|
.ToView("usa_view");
|
|
|
|
entity.Property(e => e.IdFilm).HasColumnName("id_film");
|
|
entity.Property(e => e.NameFilm)
|
|
.HasMaxLength(50)
|
|
.HasColumnName("name_film");
|
|
});
|
|
|
|
modelBuilder.Entity<User>(entity =>
|
|
{
|
|
entity.HasKey(e => e.IdUser).HasName("users_pkey");
|
|
|
|
entity.ToTable("users");
|
|
|
|
entity.Property(e => e.IdUser).HasColumnName("id_user");
|
|
entity.Property(e => e.Nikname)
|
|
.HasMaxLength(50)
|
|
.HasColumnName("nikname");
|
|
});
|
|
|
|
modelBuilder.Entity<UserRating>(entity =>
|
|
{
|
|
entity
|
|
.HasNoKey()
|
|
.ToTable("user_rating");
|
|
|
|
entity.Property(e => e.IdFilm).HasColumnName("id_film");
|
|
entity.Property(e => e.IdUser).HasColumnName("id_user");
|
|
entity.Property(e => e.Rating).HasColumnName("rating");
|
|
entity.Property(e => e.Reviev)
|
|
.HasMaxLength(255)
|
|
.HasColumnName("reviev");
|
|
|
|
entity.HasOne(d => d.IdFilmNavigation).WithMany()
|
|
.HasForeignKey(d => d.IdFilm)
|
|
.HasConstraintName("user_rating_id_film_fkey");
|
|
|
|
entity.HasOne(d => d.IdUserNavigation).WithMany()
|
|
.HasForeignKey(d => d.IdUser)
|
|
.HasConstraintName("user_rating_id_user_fkey");
|
|
});
|
|
|
|
OnModelCreatingPartial(modelBuilder);
|
|
}
|
|
|
|
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
|
|
}
|