137 lines
5.3 KiB
C#
137 lines
5.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using demka2025_sedelnikov;
|
|
|
|
namespace demka2025_sedelnikov.Context;
|
|
|
|
public partial class User8Context : DbContext
|
|
{
|
|
public User8Context()
|
|
{
|
|
}
|
|
|
|
public User8Context(DbContextOptions<User8Context> options)
|
|
: base(options)
|
|
{
|
|
}
|
|
|
|
public virtual DbSet<Materialtype> Materialtypes { get; set; }
|
|
|
|
public virtual DbSet<Partner> Partners { get; set; }
|
|
|
|
public virtual DbSet<Partnerproduct> Partnerproducts { get; set; }
|
|
|
|
public virtual DbSet<Partnertype> Partnertypes { get; set; }
|
|
|
|
public virtual DbSet<Product> Products { get; set; }
|
|
|
|
public virtual DbSet<Producttype> Producttypes { 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=45.67.56.214;Database=user8;Username=user8;Password=i9ehyuJ3;Port=5456");
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
{
|
|
modelBuilder.Entity<Materialtype>(entity =>
|
|
{
|
|
entity.HasKey(e => e.Id).HasName("materialtypes_pk");
|
|
|
|
entity.ToTable("materialtypes");
|
|
|
|
entity.Property(e => e.Id).HasColumnName("id");
|
|
entity.Property(e => e.BrakPercent).HasColumnName("brak_percent");
|
|
entity.Property(e => e.MaterialTypeName).HasColumnName("material_type_name");
|
|
});
|
|
|
|
modelBuilder.Entity<Partner>(entity =>
|
|
{
|
|
entity.HasKey(e => e.Id).HasName("partners_pk");
|
|
|
|
entity.ToTable("partners");
|
|
|
|
entity.HasIndex(e => e.Id, "partners_unique").IsUnique();
|
|
|
|
entity.Property(e => e.Id).HasColumnName("id");
|
|
entity.Property(e => e.Address).HasColumnName("address");
|
|
entity.Property(e => e.DirectorName).HasColumnName("director_name");
|
|
entity.Property(e => e.Email).HasColumnName("email");
|
|
entity.Property(e => e.Inn).HasColumnName("inn");
|
|
entity.Property(e => e.PartnerName).HasColumnName("partner_name");
|
|
entity.Property(e => e.PartnerTypeId).HasColumnName("partner_type_id");
|
|
entity.Property(e => e.Phone).HasColumnName("phone");
|
|
entity.Property(e => e.Rating).HasColumnName("rating");
|
|
|
|
entity.HasOne(d => d.PartnerType).WithMany(p => p.Partners)
|
|
.HasForeignKey(d => d.PartnerTypeId)
|
|
.HasConstraintName("partners_partnertypes_fk");
|
|
});
|
|
|
|
modelBuilder.Entity<Partnerproduct>(entity =>
|
|
{
|
|
entity.HasKey(e => e.Id).HasName("partnerproduct_pk");
|
|
|
|
entity.ToTable("partnerproduct");
|
|
|
|
entity.Property(e => e.Id).HasColumnName("id");
|
|
entity.Property(e => e.PartnerId).HasColumnName("partner_id");
|
|
entity.Property(e => e.ProductId).HasColumnName("product_id");
|
|
entity.Property(e => e.Quantity).HasColumnName("quantity");
|
|
entity.Property(e => e.SellDate).HasColumnName("sell_date");
|
|
|
|
entity.HasOne(d => d.Partner).WithMany(p => p.Partnerproducts)
|
|
.HasForeignKey(d => d.PartnerId)
|
|
.HasConstraintName("partnerproduct_partners_fk");
|
|
|
|
entity.HasOne(d => d.Product).WithMany(p => p.Partnerproducts)
|
|
.HasForeignKey(d => d.ProductId)
|
|
.HasConstraintName("partnerproduct_products_fk");
|
|
});
|
|
|
|
modelBuilder.Entity<Partnertype>(entity =>
|
|
{
|
|
entity.HasKey(e => e.Id).HasName("partnertypes_pk");
|
|
|
|
entity.ToTable("partnertypes");
|
|
|
|
entity.Property(e => e.Id).HasColumnName("id");
|
|
entity.Property(e => e.PartnerTypeName).HasColumnName("partner_type_name");
|
|
});
|
|
|
|
modelBuilder.Entity<Product>(entity =>
|
|
{
|
|
entity.HasKey(e => e.Id).HasName("products_pk");
|
|
|
|
entity.ToTable("products");
|
|
|
|
entity.Property(e => e.Id).HasColumnName("id");
|
|
entity.Property(e => e.Articul).HasColumnName("articul");
|
|
entity.Property(e => e.MinCost).HasColumnName("min_cost");
|
|
entity.Property(e => e.ProductName).HasColumnName("product_name");
|
|
entity.Property(e => e.TypeId).HasColumnName("type_id");
|
|
|
|
entity.HasOne(d => d.Type).WithMany(p => p.Products)
|
|
.HasForeignKey(d => d.TypeId)
|
|
.HasConstraintName("products_producttypes_fk");
|
|
});
|
|
|
|
modelBuilder.Entity<Producttype>(entity =>
|
|
{
|
|
entity.HasKey(e => e.Id).HasName("producttypes_pk");
|
|
|
|
entity.ToTable("producttypes");
|
|
|
|
entity.HasIndex(e => e.Id, "producttypes_unique").IsUnique();
|
|
|
|
entity.Property(e => e.Id).HasColumnName("id");
|
|
entity.Property(e => e.Coeff).HasColumnName("coeff");
|
|
entity.Property(e => e.ProductTypeName).HasColumnName("product_type_name");
|
|
});
|
|
|
|
OnModelCreatingPartial(modelBuilder);
|
|
}
|
|
|
|
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
|
|
}
|