Files
CartriX/CartriX.Shared/Classes/AppDbContext.cs
T

29 lines
997 B
C#

using Microsoft.EntityFrameworkCore;
using CartriX.Shared.Models;
namespace CartriX.Shared.Classes
{
public class AppDbContext : DbContext
{
public AppDbContext(DbContextOptions options) : base(options) { }
public DbSet<Printer> Printers { get; set; }
public DbSet<PrinterModel> PrinterModels { get; set; }
public DbSet<Location> Locations { get; set; }
public DbSet<Cartridge> Cartridges { get; set; }
public DbSet<CartridgeModel> CartridgeModels { get; set; }
public DbSet<PrintType> PrintTypes { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Location>().HasIndex(l => l.name).IsUnique();
modelBuilder.Entity<PrintType>().HasData(
new PrintType { id = 1, name = "Laser" },
new PrintType { id = 2, name = "Inkjet" }
);
base.OnModelCreating(modelBuilder);
}
}
}