43 lines
1.6 KiB
C#
43 lines
1.6 KiB
C#
using HardwareShopDatabaseImplement.Models;
|
|
using HardwareShopDatabaseImplement.Models.ManyToMany;
|
|
using HardwareShopDatabaseImplement.Models.Storekeeper;
|
|
using HardwareShopDatabaseImplement.Models.Worker;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace HardwareShopDatabaseImplement
|
|
{
|
|
public class HardwareShopDatabase : DbContext
|
|
{
|
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
|
{
|
|
optionsBuilder.UseNpgsql("Host=localhost;Port=5432;Database=Computer_Hardware_Store;Username=postgres;Password=1234");
|
|
}
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
{
|
|
modelBuilder.Entity<BuildComponent>().HasKey(x => new { x.ComponentId, x.BuildId });
|
|
modelBuilder.Entity<PurchaseBuild>().HasKey(x => new { x.PurchaseId, x.BuildId });
|
|
modelBuilder.Entity<PurchaseGood>().HasKey(x => new { x.PurchaseId, x.GoodId });
|
|
}
|
|
|
|
public virtual DbSet<Build> Builds { set; get; }
|
|
|
|
public virtual DbSet<BuildComponent> BuildsComponents { set; get; }
|
|
|
|
public virtual DbSet<Comment> Comments { set; get; }
|
|
|
|
public virtual DbSet<Component> Components { set; get; }
|
|
|
|
public virtual DbSet<Good> Goods { set; get; }
|
|
|
|
public virtual DbSet<Order> Orders { set; get; }
|
|
|
|
public virtual DbSet<Purchase> Purchases { set; get; }
|
|
|
|
public virtual DbSet<PurchaseBuild> PurchasesBuilds { set; get; }
|
|
|
|
public virtual DbSet<PurchaseGood> PurchasesGoods { set; get; }
|
|
|
|
public virtual DbSet<User> Users { set; get; }
|
|
}
|
|
} |