using System; using System.Collections.Generic; using Microsoft.EntityFrameworkCore; namespace demofinish.Models; public partial class User1Context : DbContext { public User1Context() { } public User1Context(DbContextOptions options) : base(options) { } public virtual DbSet Agents { get; set; } public virtual DbSet Agentpriorityhistories { get; set; } public virtual DbSet Agenttypes { get; set; } public virtual DbSet Materials { get; set; } public virtual DbSet Materialcounthistories { get; set; } public virtual DbSet Materialtypes { get; set; } public virtual DbSet Products { get; set; } public virtual DbSet ProductTypes { get; set; } public virtual DbSet Productcosthistories { get; set; } public virtual DbSet Productmaterials { get; set; } public virtual DbSet Productsales { get; set; } public virtual DbSet Shops { get; set; } public virtual DbSet Suppliers { 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=5421;USERNAME=user1;DATABASE=user1;Password=Xgny6RrJ"); protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Entity(entity => { entity.HasKey(e => e.Id).HasName("agent_pkey"); entity.ToTable("agent", "public2"); entity.Property(e => e.Id) .UseIdentityAlwaysColumn() .HasColumnName("id"); entity.Property(e => e.Address) .HasMaxLength(300) .HasColumnName("address"); entity.Property(e => e.Agenttypeid).HasColumnName("agenttypeid"); entity.Property(e => e.Directorname) .HasMaxLength(100) .HasColumnName("directorname"); entity.Property(e => e.Email) .HasMaxLength(255) .HasColumnName("email"); entity.Property(e => e.Inn) .HasMaxLength(12) .HasColumnName("inn"); entity.Property(e => e.Kpp) .HasMaxLength(9) .HasColumnName("kpp"); entity.Property(e => e.Logo) .HasMaxLength(100) .HasColumnName("logo"); entity.Property(e => e.Phone) .HasMaxLength(20) .HasColumnName("phone"); entity.Property(e => e.Priority).HasColumnName("priority"); entity.Property(e => e.Title) .HasMaxLength(150) .HasColumnName("title"); entity.HasOne(d => d.Agenttype).WithMany(p => p.Agents) .HasForeignKey(d => d.Agenttypeid) .OnDelete(DeleteBehavior.ClientSetNull) .HasConstraintName("fk_agent_agenttype"); }); modelBuilder.Entity(entity => { entity.HasKey(e => e.Id).HasName("agentpriorityhistory_pkey"); entity.ToTable("agentpriorityhistory", "public2"); entity.Property(e => e.Id) .UseIdentityAlwaysColumn() .HasColumnName("id"); entity.Property(e => e.Agentid).HasColumnName("agentid"); entity.Property(e => e.Changedate) .HasColumnType("timestamp without time zone") .HasColumnName("changedate"); entity.Property(e => e.Priorityvalue).HasColumnName("priorityvalue"); entity.HasOne(d => d.Agent).WithMany(p => p.Agentpriorityhistories) .HasForeignKey(d => d.Agentid) .OnDelete(DeleteBehavior.ClientSetNull) .HasConstraintName("fk_agentpriorityhistory_agent"); }); modelBuilder.Entity(entity => { entity.HasKey(e => e.Id).HasName("agenttype_pkey"); entity.ToTable("agenttype", "public2"); entity.Property(e => e.Id) .UseIdentityAlwaysColumn() .HasColumnName("id"); entity.Property(e => e.Image) .HasMaxLength(100) .HasColumnName("image"); entity.Property(e => e.Title) .HasMaxLength(50) .HasColumnName("title"); }); modelBuilder.Entity(entity => { entity.HasKey(e => e.Id).HasName("material_pkey"); entity.ToTable("material", "public2"); entity.Property(e => e.Id) .UseIdentityAlwaysColumn() .HasColumnName("id"); entity.Property(e => e.Cost) .HasPrecision(10, 2) .HasColumnName("cost"); entity.Property(e => e.Countinpack).HasColumnName("countinpack"); entity.Property(e => e.Countinstock).HasColumnName("countinstock"); entity.Property(e => e.Description).HasColumnName("description"); entity.Property(e => e.Image) .HasMaxLength(100) .HasColumnName("image"); entity.Property(e => e.Materialtypeid).HasColumnName("materialtypeid"); entity.Property(e => e.Mincount).HasColumnName("mincount"); entity.Property(e => e.Title) .HasMaxLength(100) .HasColumnName("title"); entity.Property(e => e.Unit) .HasMaxLength(10) .HasColumnName("unit"); entity.HasOne(d => d.Materialtype).WithMany(p => p.Materials) .HasForeignKey(d => d.Materialtypeid) .OnDelete(DeleteBehavior.ClientSetNull) .HasConstraintName("fk_material_materialtype"); entity.HasMany(d => d.Suppliers).WithMany(p => p.Materials) .UsingEntity>( "Materialsupplier", r => r.HasOne().WithMany() .HasForeignKey("Supplierid") .OnDelete(DeleteBehavior.ClientSetNull) .HasConstraintName("fk_materialsupplier_supplier"), l => l.HasOne().WithMany() .HasForeignKey("Materialid") .OnDelete(DeleteBehavior.ClientSetNull) .HasConstraintName("fk_materialsupplier_material"), j => { j.HasKey("Materialid", "Supplierid").HasName("materialsupplier_pkey"); j.ToTable("materialsupplier", "public2"); j.IndexerProperty("Materialid").HasColumnName("materialid"); j.IndexerProperty("Supplierid").HasColumnName("supplierid"); }); }); modelBuilder.Entity(entity => { entity.HasKey(e => e.Id).HasName("materialcounthistory_pkey"); entity.ToTable("materialcounthistory", "public2"); entity.Property(e => e.Id) .UseIdentityAlwaysColumn() .HasColumnName("id"); entity.Property(e => e.Changedate) .HasColumnType("timestamp without time zone") .HasColumnName("changedate"); entity.Property(e => e.Countvalue).HasColumnName("countvalue"); entity.Property(e => e.Materialid).HasColumnName("materialid"); entity.HasOne(d => d.Material).WithMany(p => p.Materialcounthistories) .HasForeignKey(d => d.Materialid) .OnDelete(DeleteBehavior.ClientSetNull) .HasConstraintName("fk_materialcounthistory_material"); }); modelBuilder.Entity(entity => { entity.HasKey(e => e.Id).HasName("materialtype_pkey"); entity.ToTable("materialtype", "public2"); entity.Property(e => e.Id) .UseIdentityAlwaysColumn() .HasColumnName("id"); entity.Property(e => e.Defectedpercent).HasColumnName("defectedpercent"); entity.Property(e => e.Title) .HasMaxLength(50) .HasColumnName("title"); }); modelBuilder.Entity(entity => { entity.HasKey(e => e.Id).HasName("product_pkey"); entity.ToTable("product", "public2"); entity.Property(e => e.Id) .ValueGeneratedNever() .HasColumnName("id"); entity.Property(e => e.Articlenumber) .HasMaxLength(10) .HasColumnName("articlenumber"); entity.Property(e => e.Description).HasColumnName("description"); entity.Property(e => e.Image) .HasMaxLength(100) .HasColumnName("image"); entity.Property(e => e.Mincostforagent) .HasPrecision(10, 2) .HasColumnName("mincostforagent"); entity.Property(e => e.Productionpersoncount).HasColumnName("productionpersoncount"); entity.Property(e => e.Productionworksshopnumber).HasColumnName("productionworksshopnumber"); entity.Property(e => e.Producttypeid).HasColumnName("producttypeid"); entity.Property(e => e.Title) .HasMaxLength(100) .HasColumnName("title"); }); modelBuilder.Entity(entity => { entity.HasKey(e => e.Id).HasName("ProductType_pkey"); entity.ToTable("ProductType", "public2"); entity.Property(e => e.Id).HasColumnName("ID"); entity.Property(e => e.Title).HasMaxLength(50); }); modelBuilder.Entity(entity => { entity.HasKey(e => e.Id).HasName("productcosthistory_pkey"); entity.ToTable("productcosthistory", "public2"); entity.Property(e => e.Id) .UseIdentityAlwaysColumn() .HasColumnName("id"); entity.Property(e => e.Changedate) .HasColumnType("timestamp without time zone") .HasColumnName("changedate"); entity.Property(e => e.Costvalue) .HasPrecision(10, 2) .HasColumnName("costvalue"); entity.Property(e => e.Productid).HasColumnName("productid"); }); modelBuilder.Entity(entity => { entity.HasKey(e => new { e.Productid, e.Materialid }).HasName("productmaterial_pkey"); entity.ToTable("productmaterial", "public2"); entity.Property(e => e.Productid).HasColumnName("productid"); entity.Property(e => e.Materialid).HasColumnName("materialid"); entity.Property(e => e.Count).HasColumnName("count"); entity.HasOne(d => d.Material).WithMany(p => p.Productmaterials) .HasForeignKey(d => d.Materialid) .OnDelete(DeleteBehavior.ClientSetNull) .HasConstraintName("fk_productmaterial_material"); }); modelBuilder.Entity(entity => { entity.HasKey(e => e.Id).HasName("productsale_pkey"); entity.ToTable("productsale", "public2"); entity.Property(e => e.Id) .UseIdentityAlwaysColumn() .HasColumnName("id"); entity.Property(e => e.Agentid).HasColumnName("agentid"); entity.Property(e => e.Productcount).HasColumnName("productcount"); entity.Property(e => e.Productid).HasColumnName("productid"); entity.Property(e => e.Saledate).HasColumnName("saledate"); entity.HasOne(d => d.Agent).WithMany(p => p.Productsales) .HasForeignKey(d => d.Agentid) .OnDelete(DeleteBehavior.ClientSetNull) .HasConstraintName("fk_productsale_agent"); }); modelBuilder.Entity(entity => { entity.HasKey(e => e.Id).HasName("shop_pkey"); entity.ToTable("shop", "public2"); entity.Property(e => e.Id) .UseIdentityAlwaysColumn() .HasColumnName("id"); entity.Property(e => e.Address) .HasMaxLength(300) .HasColumnName("address"); entity.Property(e => e.Agentid).HasColumnName("agentid"); entity.Property(e => e.Title) .HasMaxLength(150) .HasColumnName("title"); entity.HasOne(d => d.Agent).WithMany(p => p.Shops) .HasForeignKey(d => d.Agentid) .OnDelete(DeleteBehavior.ClientSetNull) .HasConstraintName("fk_shop_agent"); }); modelBuilder.Entity(entity => { entity.HasKey(e => e.Id).HasName("supplier_pkey"); entity.ToTable("supplier", "public2"); entity.Property(e => e.Id) .UseIdentityAlwaysColumn() .HasColumnName("id"); entity.Property(e => e.Inn) .HasMaxLength(12) .HasColumnName("inn"); entity.Property(e => e.Qualityrating).HasColumnName("qualityrating"); entity.Property(e => e.Startdate).HasColumnName("startdate"); entity.Property(e => e.Suppliertype) .HasMaxLength(20) .HasColumnName("suppliertype"); entity.Property(e => e.Title) .HasMaxLength(150) .HasColumnName("title"); }); OnModelCreatingPartial(modelBuilder); } partial void OnModelCreatingPartial(ModelBuilder modelBuilder); }