49 lines
1.5 KiB
C#
49 lines
1.5 KiB
C#
using maintenance.Data.Entities;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace maintenance.Data;
|
|
|
|
public sealed class GroupLookupDbContext : DbContext
|
|
{
|
|
public GroupLookupDbContext(DbContextOptions<GroupLookupDbContext> options) : base(options)
|
|
{
|
|
}
|
|
|
|
public DbSet<GroupLookupEntity> Groups => Set<GroupLookupEntity>();
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
{
|
|
modelBuilder.Entity<GroupLookupEntity>(e =>
|
|
{
|
|
e.ToTable("EmployeeGroup");
|
|
e.HasKey(x => x.Id);
|
|
e.Property(x => x.Id).ValueGeneratedNever();
|
|
e.Property(x => x.Name).HasMaxLength(256).IsRequired();
|
|
e.Property(x => x.EmployeeId).IsRequired();
|
|
e.HasIndex(x => x.Name);
|
|
});
|
|
}
|
|
|
|
public override int SaveChanges()
|
|
{
|
|
throw new NotSupportedException("GroupLookupDbContext is read-only.");
|
|
}
|
|
|
|
public override int SaveChanges(bool acceptAllChangesOnSuccess)
|
|
{
|
|
throw new NotSupportedException("GroupLookupDbContext is read-only.");
|
|
}
|
|
|
|
public override Task<int> SaveChangesAsync(CancellationToken cancellationToken = default)
|
|
{
|
|
throw new NotSupportedException("GroupLookupDbContext is read-only.");
|
|
}
|
|
|
|
public override Task<int> SaveChangesAsync(
|
|
bool acceptAllChangesOnSuccess,
|
|
CancellationToken cancellationToken = default)
|
|
{
|
|
throw new NotSupportedException("GroupLookupDbContext is read-only.");
|
|
}
|
|
}
|