223 lines
8.6 KiB
C#
223 lines
8.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using tiron_demo.Models;
|
|
|
|
namespace tiron_demo.Context;
|
|
|
|
public partial class User20Context : DbContext
|
|
{
|
|
public User20Context()
|
|
{
|
|
}
|
|
|
|
public User20Context(DbContextOptions<User20Context> options)
|
|
: base(options)
|
|
{
|
|
}
|
|
|
|
public virtual DbSet<Material> Materials { get; set; }
|
|
|
|
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; }
|
|
|
|
public virtual DbSet<ProductsMinCostHistory> ProductsMinCostHistories { 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 https://go.microsoft.com/fwlink/?LinkId=723263.
|
|
=> optionsBuilder.UseNpgsql("Host=45.67.56.214;Port=5456;Database=user20;Username=user20;Password=uFTJmxd5");
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
{
|
|
modelBuilder.Entity<Material>(entity =>
|
|
{
|
|
entity.HasKey(e => e.Id).HasName("materials_pk");
|
|
|
|
entity.ToTable("materials");
|
|
|
|
entity.HasIndex(e => e.Name, "materials_unique").IsUnique();
|
|
|
|
entity.Property(e => e.Id).HasColumnName("id");
|
|
entity.Property(e => e.AmountPerPackage).HasColumnName("amount_per_package");
|
|
entity.Property(e => e.Cost).HasColumnName("cost");
|
|
entity.Property(e => e.MeasureUnit)
|
|
.HasColumnType("character varying")
|
|
.HasColumnName("measure_unit");
|
|
entity.Property(e => e.MinAmount)
|
|
.HasDefaultValue(0)
|
|
.HasColumnName("min_amount");
|
|
entity.Property(e => e.Name)
|
|
.HasColumnType("character varying")
|
|
.HasColumnName("name");
|
|
entity.Property(e => e.StorageAmount)
|
|
.HasDefaultValue(0)
|
|
.HasColumnName("storage_amount");
|
|
entity.Property(e => e.Type).HasColumnName("type");
|
|
|
|
entity.HasOne(d => d.TypeNavigation).WithMany(p => p.Materials)
|
|
.HasForeignKey(d => d.Type)
|
|
.OnDelete(DeleteBehavior.ClientSetNull)
|
|
.HasConstraintName("materials_material_type_fk");
|
|
});
|
|
|
|
modelBuilder.Entity<MaterialType>(entity =>
|
|
{
|
|
entity.HasKey(e => e.Id).HasName("material_type_pk");
|
|
|
|
entity.ToTable("material_type");
|
|
|
|
entity.HasIndex(e => e.Name, "material_type_unique").IsUnique();
|
|
|
|
entity.Property(e => e.Id).HasColumnName("id");
|
|
entity.Property(e => e.DefectRate).HasColumnName("defect_rate");
|
|
entity.Property(e => e.Name)
|
|
.HasColumnType("character varying")
|
|
.HasColumnName("name");
|
|
});
|
|
|
|
modelBuilder.Entity<Partner>(entity =>
|
|
{
|
|
entity.HasKey(e => e.Id).HasName("partners_pk");
|
|
|
|
entity.ToTable("partners");
|
|
|
|
entity.Property(e => e.Id).HasColumnName("id");
|
|
entity.Property(e => e.Address)
|
|
.HasColumnType("character varying")
|
|
.HasColumnName("address");
|
|
entity.Property(e => e.Director)
|
|
.HasColumnType("character varying")
|
|
.HasColumnName("director");
|
|
entity.Property(e => e.Email)
|
|
.HasColumnType("character varying")
|
|
.HasColumnName("email");
|
|
entity.Property(e => e.Inn)
|
|
.HasColumnType("character varying")
|
|
.HasColumnName("inn");
|
|
entity.Property(e => e.Name)
|
|
.HasColumnType("character varying")
|
|
.HasColumnName("name");
|
|
entity.Property(e => e.Phone)
|
|
.HasColumnType("character varying")
|
|
.HasColumnName("phone");
|
|
entity.Property(e => e.Rating)
|
|
.HasDefaultValue((short)0)
|
|
.HasColumnName("rating");
|
|
entity.Property(e => e.Type).HasColumnName("type");
|
|
|
|
entity.HasOne(d => d.TypeNavigation).WithMany(p => p.Partners)
|
|
.HasForeignKey(d => d.Type)
|
|
.OnDelete(DeleteBehavior.ClientSetNull)
|
|
.HasConstraintName("partners_partner_type_fk");
|
|
});
|
|
|
|
modelBuilder.Entity<PartnerProduct>(entity =>
|
|
{
|
|
entity.HasKey(e => e.Id).HasName("partner_products_pk");
|
|
|
|
entity.ToTable("partner_products");
|
|
|
|
entity.Property(e => e.Id).HasColumnName("id");
|
|
entity.Property(e => e.Amount)
|
|
.HasDefaultValue(0)
|
|
.HasColumnName("amount");
|
|
entity.Property(e => e.Partner).HasColumnName("partner");
|
|
entity.Property(e => e.Product).HasColumnName("product");
|
|
entity.Property(e => e.SellDate).HasColumnName("sell_date");
|
|
|
|
entity.HasOne(d => d.PartnerNavigation).WithMany(p => p.PartnerProducts)
|
|
.HasForeignKey(d => d.Partner)
|
|
.OnDelete(DeleteBehavior.ClientSetNull)
|
|
.HasConstraintName("partner_products_partners_fk");
|
|
|
|
entity.HasOne(d => d.ProductNavigation).WithMany(p => p.PartnerProducts)
|
|
.HasForeignKey(d => d.Product)
|
|
.OnDelete(DeleteBehavior.ClientSetNull)
|
|
.HasConstraintName("partner_products_products_fk");
|
|
});
|
|
|
|
modelBuilder.Entity<PartnerType>(entity =>
|
|
{
|
|
entity.HasKey(e => e.Id).HasName("partner_type_pk");
|
|
|
|
entity.ToTable("partner_type");
|
|
|
|
entity.HasIndex(e => e.Name, "partner_type_unique").IsUnique();
|
|
|
|
entity.Property(e => e.Id).HasColumnName("id");
|
|
entity.Property(e => e.Name)
|
|
.HasColumnType("character varying")
|
|
.HasColumnName("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)
|
|
.HasColumnType("character varying")
|
|
.HasColumnName("articul");
|
|
entity.Property(e => e.MinCost).HasColumnName("min_cost");
|
|
entity.Property(e => e.Name)
|
|
.HasColumnType("character varying")
|
|
.HasColumnName("name");
|
|
entity.Property(e => e.Type).HasColumnName("type");
|
|
|
|
entity.HasOne(d => d.TypeNavigation).WithMany(p => p.Products)
|
|
.HasForeignKey(d => d.Type)
|
|
.OnDelete(DeleteBehavior.ClientSetNull)
|
|
.HasConstraintName("products_product_type_fk");
|
|
});
|
|
|
|
modelBuilder.Entity<ProductType>(entity =>
|
|
{
|
|
entity.HasKey(e => e.Id).HasName("product_type_pk");
|
|
|
|
entity.ToTable("product_type");
|
|
|
|
entity.HasIndex(e => e.Name, "product_type_unique").IsUnique();
|
|
|
|
entity.Property(e => e.Id).HasColumnName("id");
|
|
entity.Property(e => e.K).HasColumnName("k");
|
|
entity.Property(e => e.Name)
|
|
.HasColumnType("character varying")
|
|
.HasColumnName("name");
|
|
});
|
|
|
|
modelBuilder.Entity<ProductsMinCostHistory>(entity =>
|
|
{
|
|
entity.HasKey(e => e.Id).HasName("products_min_cost_history_pk");
|
|
|
|
entity.ToTable("products_min_cost_history");
|
|
|
|
entity.Property(e => e.Id).HasColumnName("id");
|
|
entity.Property(e => e.Date)
|
|
.HasColumnType("timestamp without time zone")
|
|
.HasColumnName("date");
|
|
entity.Property(e => e.MinCost).HasColumnName("min_cost");
|
|
entity.Property(e => e.Product).HasColumnName("product");
|
|
|
|
entity.HasOne(d => d.ProductNavigation).WithMany(p => p.ProductsMinCostHistories)
|
|
.HasForeignKey(d => d.Product)
|
|
.OnDelete(DeleteBehavior.ClientSetNull)
|
|
.HasConstraintName("products_min_cost_history_products_fk");
|
|
});
|
|
|
|
OnModelCreatingPartial(modelBuilder);
|
|
}
|
|
|
|
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
|
|
}
|