2023-04-01 14:32:31 +04:00
|
|
|
|
using HardwareShopDatabaseImplement.Models;
|
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
|
|
|
|
|
namespace HardwareShopDatabaseImplement
|
|
|
|
|
{
|
|
|
|
|
public class HardwareShopDatabase : DbContext
|
|
|
|
|
{
|
|
|
|
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
|
|
|
|
{
|
|
|
|
|
if (optionsBuilder.IsConfigured == false)
|
|
|
|
|
{
|
|
|
|
|
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-SINQU55\SQLEXPRESS;Initial Catalog=HardwareShopDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
|
|
|
|
}
|
|
|
|
|
base.OnConfiguring(optionsBuilder);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
|
|
|
{
|
|
|
|
|
modelBuilder.Entity<BuildComponent>().HasKey(x => new { x.ComponentId, x.BuildID });
|
2023-04-01 14:38:20 +04:00
|
|
|
|
modelBuilder.Entity<PurchaseBuild>().HasKey(x => new { x.PurchaseID, x.BuildID });
|
|
|
|
|
modelBuilder.Entity<PurchaseGood>().HasKey(x => new { x.PurchaseID, x.GoodID });
|
2023-04-01 14:32:31 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual DbSet<Build> Builds { set; get; }
|
|
|
|
|
|
2023-04-01 14:53:34 +04:00
|
|
|
|
public virtual DbSet<BuildComponent> BuildsComponents { set; get; }
|
|
|
|
|
|
2023-04-01 14:32:31 +04:00
|
|
|
|
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; }
|
|
|
|
|
|
2023-04-01 16:27:37 +04:00
|
|
|
|
public virtual DbSet<Purchase> Purchases { set; get; }
|
2023-04-01 14:32:31 +04:00
|
|
|
|
|
|
|
|
|
public virtual DbSet<PurchaseBuild> PurchasesBuilds { set; get; }
|
|
|
|
|
|
|
|
|
|
public virtual DbSet<PurchaseGood> PurchasesGoods { set; get; }
|
|
|
|
|
|
|
|
|
|
public virtual DbSet<User> Users { set; get; }
|
|
|
|
|
}
|
|
|
|
|
}
|