RDBMS/RDBMS_lab4/beautySalonContext.cs
2024-05-12 17:52:28 +04:00

119 lines
5.1 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// <auto-generated> This file has been auto generated by EF Core Power Tools. </auto-generated>
#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<beautySalonContext> options)
: base(options)
{
}
public virtual DbSet<Buyer> Buyers { get; set; }
public virtual DbSet<Post> Posts { get; set; }
public virtual DbSet<Service> Services { get; set; }
public virtual DbSet<Timetable> Timetables { get; set; }
public virtual DbSet<Worker> 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<Buyer>(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<Post>(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<Dictionary<string, object>>(
"PostService",
r => r.HasOne<Service>().WithMany()
.HasForeignKey("Serviceid")
.HasConstraintName("post_service_serviceid_fkey"),
l => l.HasOne<Post>().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<int>("Postid").HasColumnName("postid");
j.IndexerProperty<int>("Serviceid").HasColumnName("serviceid");
});
});
modelBuilder.Entity<Service>(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<Timetable>(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<Worker>(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);
}