// This file has been auto generated by EF Core Power Tools.
#nullable disable
using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
using RDBMS_lab4.Models;
namespace RDBMS_lab4;
public partial class beautySalonContext : DbContext
{
public beautySalonContext()
{
}
public beautySalonContext(DbContextOptions options)
: base(options)
{
}
public virtual DbSet Buyers { get; set; }
public virtual DbSet Posts { get; set; }
public virtual DbSet Services { get; set; }
public virtual DbSet Timetables { get; set; }
public virtual DbSet Workers { 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=192.168.1.70;Database=beautySalon;Username=windows;Password=windows");
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
AppContext.SetSwitch("Npgsql.DisableDateTimeInfinityConversions", true);
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity(entity =>
{
entity.HasKey(e => e.Id).HasName("buyer_pkey");
entity.ToTable("buyers", tb => tb.HasComment("Таблица клиентов"));
entity.Property(e => e.Id).HasDefaultValueSql("nextval('buyer_id_seq'::regclass)");
});
modelBuilder.Entity(entity =>
{
entity.HasKey(e => e.Id).HasName("Post_pkey");
entity.ToTable("posts", tb => tb.HasComment("Таблица с должностями работников"));
entity.Property(e => e.Id).HasDefaultValueSql("nextval('post_id_seq'::regclass)");
entity.HasMany(d => d.Services).WithMany(p => p.Posts)
.UsingEntity>(
"PostService",
r => r.HasOne().WithMany()
.HasForeignKey("Serviceid")
.HasConstraintName("post_service_serviceid_fkey"),
l => l.HasOne().WithMany()
.HasForeignKey("Postid")
.HasConstraintName("post_service_postid_fkey"),
j =>
{
j.HasKey("Postid", "Serviceid").HasName("post_service_pkey");
j.ToTable("post_service", tb => tb.HasComment("Связь должностей и услуг"));
j.HasIndex(new[] { "Postid" }, "fki_post_service_postid_fkey");
j.HasIndex(new[] { "Serviceid" }, "fki_post_service_serviceid_fkey");
j.IndexerProperty("Postid").HasColumnName("postid");
j.IndexerProperty("Serviceid").HasColumnName("serviceid");
});
});
modelBuilder.Entity(entity =>
{
entity.HasKey(e => e.Id).HasName("service_pkey");
entity.ToTable("services", tb => tb.HasComment("Таблица услуг"));
entity.Property(e => e.Id).HasDefaultValueSql("nextval('service_id_seq'::regclass)");
});
modelBuilder.Entity(entity =>
{
entity.HasKey(e => e.Buyerid).HasName("timetable_pkey");
entity.ToTable("timetable", tb => tb.HasComment("Таблица расписания, содержит ссылки на клиента, услугу и работника"));
entity.Property(e => e.Buyerid).ValueGeneratedNever();
entity.Property(e => e.Date).HasDefaultValueSql("CURRENT_DATE");
entity.Property(e => e.Id).ValueGeneratedOnAdd();
entity.HasOne(d => d.Buyer).WithOne(p => p.Timetable).HasConstraintName("timetable_buyerid_fkey");
entity.HasOne(d => d.Service).WithMany(p => p.Timetables).HasConstraintName("timetable_serviceid_fkey");
entity.HasOne(d => d.Worker).WithMany(p => p.Timetables).HasConstraintName("timetable_workerid_fkey");
});
modelBuilder.Entity(entity =>
{
entity.HasKey(e => e.Id).HasName("workers_pkey");
entity.ToTable("workers", tb => tb.HasComment("Таблица работников, содержит ссылку на должность"));
entity.Property(e => e.Id).HasDefaultValueSql("nextval('worker_id_seq'::regclass)");
entity.HasOne(d => d.Post).WithMany(p => p.Workers).HasConstraintName("workers_postid_fkey");
});
OnModelCreatingPartial(modelBuilder);
}
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
}