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().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 }); } 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 Orders { set; get; } public virtual DbSet Purchase { set; get; } public virtual DbSet PurchasesBuilds { set; get; } public virtual DbSet PurchasesGoods { set; get; } public virtual DbSet Users { set; get; } } }