30 lines
1.2 KiB
C#
30 lines
1.2 KiB
C#
|
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; }
|
|||
|
}
|
|||
|
}
|