Subd/SubdShoeStore/Shoestorelab5Context.cs
Никита Чернышов a0b3663381 вытяжка бд
2023-05-04 01:47:30 +04:00

125 lines
4.7 KiB
C#

using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
namespace SubdShoeStore;
public partial class Shoestorelab5Context : DbContext
{
public Shoestorelab5Context()
{
}
public Shoestorelab5Context(DbContextOptions<Shoestorelab5Context> options)
: base(options)
{
}
public virtual DbSet<Consignment> Consignments { get; set; }
public virtual DbSet<Range> Ranges { get; set; }
public virtual DbSet<Seller> Sellers { get; set; }
public virtual DbSet<Selling> Sellings { 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.56.101;Port=5432;Database=shoestorelab5;Username=postgres;Password=1804");
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Consignment>(entity =>
{
entity.HasKey(e => e.Consignmentid).HasName("consignmentpk");
entity.ToTable("consignment");
entity.Property(e => e.Consignmentid)
.HasDefaultValueSql("nextval('seq_consignment'::regclass)")
.HasColumnName("consignmentid");
entity.Property(e => e.Amount).HasColumnName("amount");
entity.Property(e => e.EnterDate).HasColumnName("enter_date");
entity.Property(e => e.Rangeid).HasColumnName("rangeid");
entity.Property(e => e.Size).HasColumnName("size");
entity.HasOne(d => d.Range).WithMany(p => p.Consignments)
.HasForeignKey(d => d.Rangeid)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("rangeconsignmentfk");
});
modelBuilder.Entity<Range>(entity =>
{
entity.HasKey(e => e.Rangeid).HasName("rangepk");
entity.ToTable("range");
entity.Property(e => e.Rangeid)
.HasDefaultValueSql("nextval('seq_range'::regclass)")
.HasColumnName("rangeid");
entity.Property(e => e.Mfr)
.HasMaxLength(50)
.HasColumnName("mfr");
entity.Property(e => e.Price)
.HasPrecision(10, 2)
.HasColumnName("price");
entity.Property(e => e.Shoename)
.HasMaxLength(50)
.HasColumnName("shoename");
});
modelBuilder.Entity<Seller>(entity =>
{
entity.HasKey(e => e.Sellerid).HasName("sellerpk");
entity.ToTable("seller");
entity.Property(e => e.Sellerid)
.HasDefaultValueSql("nextval('seq_seller'::regclass)")
.HasColumnName("sellerid");
entity.Property(e => e.Name)
.HasMaxLength(50)
.HasColumnName("name");
entity.Property(e => e.PhoneNumber)
.HasMaxLength(50)
.HasColumnName("phone_number");
entity.Property(e => e.Surname)
.HasMaxLength(50)
.HasColumnName("surname");
});
modelBuilder.Entity<Selling>(entity =>
{
entity.HasKey(e => e.Sellingid).HasName("sellingpk");
entity.ToTable("selling");
entity.Property(e => e.Sellingid)
.HasDefaultValueSql("nextval('seq_selling'::regclass)")
.HasColumnName("sellingid");
entity.Property(e => e.Consignmentid).HasColumnName("consignmentid");
entity.Property(e => e.SellDate).HasColumnName("sell_date");
entity.Property(e => e.Sellerid).HasColumnName("sellerid");
entity.HasOne(d => d.Consignment).WithMany(p => p.Sellings)
.HasForeignKey(d => d.Consignmentid)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("consignmentfk");
entity.HasOne(d => d.Seller).WithMany(p => p.Sellings)
.HasForeignKey(d => d.Sellerid)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("sellerfk");
});
modelBuilder.HasSequence("seq_consignment");
modelBuilder.HasSequence("seq_range");
modelBuilder.HasSequence("seq_seller");
modelBuilder.HasSequence("seq_selling");
OnModelCreatingPartial(modelBuilder);
}
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
}