226 lines
9.1 KiB
C#
226 lines
9.1 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using Microsoft.EntityFrameworkCore;
|
|||
|
|
|||
|
namespace demo_trade.Data.RemoteData.Entity;
|
|||
|
|
|||
|
public partial class TradeContext : DbContext
|
|||
|
{
|
|||
|
public TradeContext()
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
public TradeContext(DbContextOptions<TradeContext> options)
|
|||
|
: base(options)
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
public virtual DbSet<Category> Categories { get; set; }
|
|||
|
|
|||
|
public virtual DbSet<Manufacturer> Manufacturers { get; set; }
|
|||
|
|
|||
|
public virtual DbSet<Order> Orders { get; set; }
|
|||
|
|
|||
|
public virtual DbSet<Orderproduct> Orderproducts { get; set; }
|
|||
|
|
|||
|
public virtual DbSet<PickupPoint> PickupPoints { get; set; }
|
|||
|
|
|||
|
public virtual DbSet<Porductprovider> Porductproviders { get; set; }
|
|||
|
|
|||
|
public virtual DbSet<Product> Products { get; set; }
|
|||
|
|
|||
|
public virtual DbSet<Productunit> Productunits { get; set; }
|
|||
|
|
|||
|
public virtual DbSet<Role> Roles { get; set; }
|
|||
|
|
|||
|
public virtual DbSet<User> Users { 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=localhost;Username=postgres;Database=trade;Password=Student");
|
|||
|
|
|||
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|||
|
{
|
|||
|
modelBuilder.Entity<Category>(entity =>
|
|||
|
{
|
|||
|
entity.HasKey(e => e.CategoryId).HasName("category_pkey");
|
|||
|
|
|||
|
entity.ToTable("category");
|
|||
|
|
|||
|
entity.Property(e => e.CategoryId)
|
|||
|
.UseIdentityAlwaysColumn()
|
|||
|
.HasColumnName("category_id");
|
|||
|
entity.Property(e => e.CategoryName).HasColumnName("category_name");
|
|||
|
});
|
|||
|
|
|||
|
modelBuilder.Entity<Manufacturer>(entity =>
|
|||
|
{
|
|||
|
entity.HasKey(e => e.ManufacturerId).HasName("manufacturer_pkey");
|
|||
|
|
|||
|
entity.ToTable("manufacturer");
|
|||
|
|
|||
|
entity.Property(e => e.ManufacturerId)
|
|||
|
.UseIdentityAlwaysColumn()
|
|||
|
.HasColumnName("manufacturer_id");
|
|||
|
entity.Property(e => e.ManufacturerName).HasColumnName("manufacturer_name");
|
|||
|
});
|
|||
|
|
|||
|
modelBuilder.Entity<Order>(entity =>
|
|||
|
{
|
|||
|
entity.HasKey(e => e.Orderid).HasName("Order_pkey");
|
|||
|
|
|||
|
entity.ToTable("Order");
|
|||
|
|
|||
|
entity.Property(e => e.Orderid)
|
|||
|
.UseIdentityAlwaysColumn()
|
|||
|
.HasColumnName("orderid");
|
|||
|
entity.Property(e => e.Orderdeliverydate).HasColumnName("orderdeliverydate");
|
|||
|
entity.Property(e => e.Orderpickuppoint).HasColumnName("orderpickuppoint");
|
|||
|
entity.Property(e => e.Orderstatus).HasColumnName("orderstatus");
|
|||
|
entity.Property(e => e.ClientName).HasColumnName("client_name");
|
|||
|
entity.Property(e => e.OrderSumCost).HasColumnName("order_sum_cost");
|
|||
|
|
|||
|
entity.HasOne(d => d.OrderpickuppointNavigation).WithMany(p => p.Orders)
|
|||
|
.HasForeignKey(d => d.Orderpickuppoint)
|
|||
|
.OnDelete(DeleteBehavior.ClientSetNull)
|
|||
|
.HasConstraintName("Order_orderpickuppoint_fkey");
|
|||
|
});
|
|||
|
|
|||
|
modelBuilder.Entity<Orderproduct>(entity =>
|
|||
|
{
|
|||
|
entity.HasKey(e => new { e.Orderid, e.Productarticlenumber }).HasName("orderproduct_pkey");
|
|||
|
|
|||
|
entity.ToTable("orderproduct");
|
|||
|
|
|||
|
entity.Property(e => e.Orderid).HasColumnName("orderid");
|
|||
|
entity.Property(e => e.Productarticlenumber).HasColumnName("productarticlenumber");
|
|||
|
entity.Property(e => e.ProductCount).HasColumnName("product_count");
|
|||
|
|
|||
|
entity.HasOne(d => d.Order).WithMany(p => p.Orderproducts)
|
|||
|
.HasForeignKey(d => d.Orderid)
|
|||
|
.OnDelete(DeleteBehavior.ClientSetNull)
|
|||
|
.HasConstraintName("orderproduct_orderid_fkey");
|
|||
|
|
|||
|
entity.HasOne(d => d.ProductarticlenumberNavigation).WithMany(p => p.Orderproducts)
|
|||
|
.HasForeignKey(d => d.Productarticlenumber)
|
|||
|
.OnDelete(DeleteBehavior.ClientSetNull)
|
|||
|
.HasConstraintName("orderproduct_productarticlenumber_fkey");
|
|||
|
});
|
|||
|
|
|||
|
modelBuilder.Entity<PickupPoint>(entity =>
|
|||
|
{
|
|||
|
entity.HasKey(e => e.PickupPointId).HasName("pickup_point_pkey");
|
|||
|
|
|||
|
entity.ToTable("pickup_point");
|
|||
|
|
|||
|
entity.Property(e => e.PickupPointId)
|
|||
|
.UseIdentityAlwaysColumn()
|
|||
|
.HasColumnName("pickup_point_id");
|
|||
|
entity.Property(e => e.PickupPointName).HasColumnName("pickup_point_name");
|
|||
|
});
|
|||
|
|
|||
|
modelBuilder.Entity<Porductprovider>(entity =>
|
|||
|
{
|
|||
|
entity.HasKey(e => e.PorductproviderId).HasName("porductprovider_pkey");
|
|||
|
|
|||
|
entity.ToTable("porductprovider");
|
|||
|
|
|||
|
entity.Property(e => e.PorductproviderId)
|
|||
|
.UseIdentityAlwaysColumn()
|
|||
|
.HasColumnName("porductprovider_id");
|
|||
|
entity.Property(e => e.PorductproviderName).HasColumnName("porductprovider_name");
|
|||
|
});
|
|||
|
|
|||
|
modelBuilder.Entity<Product>(entity =>
|
|||
|
{
|
|||
|
entity.HasKey(e => e.Productarticlenumber).HasName("product_pkey1");
|
|||
|
|
|||
|
entity.ToTable("product");
|
|||
|
|
|||
|
entity.Property(e => e.Productarticlenumber).HasColumnName("productarticlenumber");
|
|||
|
entity.Property(e => e.CategoryId).HasColumnName("category_id");
|
|||
|
entity.Property(e => e.Imagename)
|
|||
|
.HasMaxLength(50)
|
|||
|
.HasColumnName("imagename");
|
|||
|
entity.Property(e => e.ManufacturerId).HasColumnName("manufacturer_id");
|
|||
|
entity.Property(e => e.PorductproviderId).HasColumnName("porductprovider_id");
|
|||
|
entity.Property(e => e.Productcost)
|
|||
|
.HasPrecision(19, 4)
|
|||
|
.HasColumnName("productcost");
|
|||
|
entity.Property(e => e.Productdescription).HasColumnName("productdescription");
|
|||
|
entity.Property(e => e.Productdiscountamount).HasColumnName("productdiscountamount");
|
|||
|
entity.Property(e => e.Productmaxdiscount).HasColumnName("productmaxdiscount");
|
|||
|
entity.Property(e => e.Productname).HasColumnName("productname");
|
|||
|
entity.Property(e => e.Productphoto).HasColumnName("productphoto");
|
|||
|
entity.Property(e => e.Productquantityinstock).HasColumnName("productquantityinstock");
|
|||
|
entity.Property(e => e.UnitId).HasColumnName("unit_id");
|
|||
|
|
|||
|
entity.HasOne(d => d.Category).WithMany(p => p.Products)
|
|||
|
.HasForeignKey(d => d.CategoryId)
|
|||
|
.HasConstraintName("product_category_id_fkey");
|
|||
|
|
|||
|
entity.HasOne(d => d.Manufacturer).WithMany(p => p.Products)
|
|||
|
.HasForeignKey(d => d.ManufacturerId)
|
|||
|
.HasConstraintName("product_manufacturer_id_fkey");
|
|||
|
|
|||
|
entity.HasOne(d => d.Porductprovider).WithMany(p => p.Products)
|
|||
|
.HasForeignKey(d => d.PorductproviderId)
|
|||
|
.HasConstraintName("product_porductprovider_id_fkey");
|
|||
|
|
|||
|
entity.HasOne(d => d.Unit).WithMany(p => p.Products)
|
|||
|
.HasForeignKey(d => d.UnitId)
|
|||
|
.HasConstraintName("product_unit_id_fkey1");
|
|||
|
});
|
|||
|
|
|||
|
modelBuilder.Entity<Productunit>(entity =>
|
|||
|
{
|
|||
|
entity.HasKey(e => e.UnitId).HasName("productunit_pkey");
|
|||
|
|
|||
|
entity.ToTable("productunit");
|
|||
|
|
|||
|
entity.Property(e => e.UnitId)
|
|||
|
.UseIdentityAlwaysColumn()
|
|||
|
.HasColumnName("unit_id");
|
|||
|
entity.Property(e => e.UnitName).HasColumnName("unit_name");
|
|||
|
});
|
|||
|
|
|||
|
modelBuilder.Entity<Role>(entity =>
|
|||
|
{
|
|||
|
entity.HasKey(e => e.Roleid).HasName("Role_pkey");
|
|||
|
|
|||
|
entity.ToTable("Role");
|
|||
|
|
|||
|
entity.Property(e => e.Roleid)
|
|||
|
.UseIdentityAlwaysColumn()
|
|||
|
.HasColumnName("roleid");
|
|||
|
entity.Property(e => e.Rolename).HasColumnName("rolename");
|
|||
|
});
|
|||
|
|
|||
|
modelBuilder.Entity<User>(entity =>
|
|||
|
{
|
|||
|
entity.HasKey(e => e.Userid).HasName("User_pkey");
|
|||
|
|
|||
|
entity.ToTable("User");
|
|||
|
|
|||
|
entity.Property(e => e.Userid)
|
|||
|
.UseIdentityAlwaysColumn()
|
|||
|
.HasColumnName("userid");
|
|||
|
entity.Property(e => e.Userlogin).HasColumnName("userlogin");
|
|||
|
entity.Property(e => e.Username).HasColumnName("username");
|
|||
|
entity.Property(e => e.Userpassword).HasColumnName("userpassword");
|
|||
|
entity.Property(e => e.Userpatronymic).HasColumnName("userpatronymic");
|
|||
|
entity.Property(e => e.Userrole).HasColumnName("userrole");
|
|||
|
entity.Property(e => e.Usersurname).HasColumnName("usersurname");
|
|||
|
|
|||
|
entity.HasOne(d => d.UserroleNavigation).WithMany(p => p.Users)
|
|||
|
.HasForeignKey(d => d.Userrole)
|
|||
|
.OnDelete(DeleteBehavior.ClientSetNull)
|
|||
|
.HasConstraintName("User_userrole_fkey");
|
|||
|
});
|
|||
|
|
|||
|
OnModelCreatingPartial(modelBuilder);
|
|||
|
}
|
|||
|
|
|||
|
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
|
|||
|
}
|