вытяжка бд
This commit is contained in:
parent
e133fd132f
commit
a0b3663381
21
SubdShoeStore/Consignment.cs
Normal file
21
SubdShoeStore/Consignment.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SubdShoeStore;
|
||||
|
||||
public partial class Consignment
|
||||
{
|
||||
public int Consignmentid { get; set; }
|
||||
|
||||
public int Size { get; set; }
|
||||
|
||||
public int Amount { get; set; }
|
||||
|
||||
public DateOnly EnterDate { get; set; }
|
||||
|
||||
public int Rangeid { get; set; }
|
||||
|
||||
public virtual Range Range { get; set; } = null!;
|
||||
|
||||
public virtual ICollection<Selling> Sellings { get; set; } = new List<Selling>();
|
||||
}
|
17
SubdShoeStore/Range.cs
Normal file
17
SubdShoeStore/Range.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SubdShoeStore;
|
||||
|
||||
public partial class Range
|
||||
{
|
||||
public int Rangeid { get; set; }
|
||||
|
||||
public string Shoename { get; set; } = null!;
|
||||
|
||||
public string Mfr { get; set; } = null!;
|
||||
|
||||
public decimal Price { get; set; }
|
||||
|
||||
public virtual ICollection<Consignment> Consignments { get; set; } = new List<Consignment>();
|
||||
}
|
17
SubdShoeStore/Seller.cs
Normal file
17
SubdShoeStore/Seller.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SubdShoeStore;
|
||||
|
||||
public partial class Seller
|
||||
{
|
||||
public int Sellerid { get; set; }
|
||||
|
||||
public string Surname { get; set; } = null!;
|
||||
|
||||
public string Name { get; set; } = null!;
|
||||
|
||||
public string PhoneNumber { get; set; } = null!;
|
||||
|
||||
public virtual ICollection<Selling> Sellings { get; set; } = new List<Selling>();
|
||||
}
|
19
SubdShoeStore/Selling.cs
Normal file
19
SubdShoeStore/Selling.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SubdShoeStore;
|
||||
|
||||
public partial class Selling
|
||||
{
|
||||
public int Sellingid { get; set; }
|
||||
|
||||
public int Sellerid { get; set; }
|
||||
|
||||
public int Consignmentid { get; set; }
|
||||
|
||||
public DateOnly SellDate { get; set; }
|
||||
|
||||
public virtual Consignment Consignment { get; set; } = null!;
|
||||
|
||||
public virtual Seller Seller { get; set; } = null!;
|
||||
}
|
124
SubdShoeStore/Shoestorelab5Context.cs
Normal file
124
SubdShoeStore/Shoestorelab5Context.cs
Normal file
@ -0,0 +1,124 @@
|
||||
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);
|
||||
}
|
@ -7,4 +7,13 @@
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ConsoleTableExt" Version="3.2.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.5">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.4" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
Loading…
Reference in New Issue
Block a user