PIbd-23_Elatomtsev_L.K._SUB.../DeviceDatabaseImplement/DeviceDataModels.cs

30 lines
1.2 KiB
C#
Raw Normal View History

2024-05-20 05:17:39 +04:00
using DeviceDatabaseImplement.Models;
using Microsoft.EntityFrameworkCore;
namespace DeviceDatabaseImplement
{
public class DeviceDatabase : DbContext
{
protected override void OnConfiguring(
DbContextOptionsBuilder optionsBuilder)
{
if (optionsBuilder.IsConfigured == false)
{
optionsBuilder.UseSqlServer(@"Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=ConfectioneryDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
}
base.OnConfiguring(optionsBuilder);
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Ownership>()
.HasKey(sc => new { sc.StaffId, sc.KitId });
}
public virtual DbSet<Cabinet> Cabinets { set; get; }
public virtual DbSet<Device> Devices { set; get; }
public virtual DbSet<Kind> Kinds { set; get; }
public virtual DbSet<Kit> Kits { set; get; }
public virtual DbSet<Service> Services { set; get; }
public virtual DbSet<Staff> Staff { set; get; }
public virtual DbSet<Ownership> Ownership { set; get; }
}
}