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) { if (optionsBuilder.IsConfigured == false) { optionsBuilder.UseNpgsql("Host=192.168.0.101;Port=5432;Database=Computer_Hardware_Store;Username=user;Password=12345"); } base.OnConfiguring(optionsBuilder); } protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Entity().HasKey(x => new { x.ComponentId, x.BuildId }); modelBuilder.Entity().HasKey(x => new { x.PurchaseId, x.BuildId }); modelBuilder.Entity().HasKey(x => new { x.PurchaseId, x.GoodId }); modelBuilder.Entity().HasKey(x => new { x.GoodId, x.ComponentId }); } public virtual DbSet Builds { set; get; } public virtual DbSet BuildsComponents { set; get; } public virtual DbSet Comments { set; get; } public virtual DbSet Components { set; get; } public virtual DbSet Goods { set; get; } public virtual DbSet GoodComponents { set; get; } public virtual DbSet Orders { set; get; } public virtual DbSet Purchases { set; get; } public virtual DbSet PurchasesBuilds { set; get; } public virtual DbSet PurchasesGoods { set; get; } public virtual DbSet Users { set; get; } } }