33 lines
1011 B
C#
33 lines
1011 B
C#
using Manager.Data.Models.ApplicationContext;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace Manager.Data.Contexts;
|
|
|
|
public sealed class ApplicationDbContext : DbContext
|
|
{
|
|
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options)
|
|
{
|
|
ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;
|
|
ChangeTracker.LazyLoadingEnabled = false;
|
|
}
|
|
|
|
public DbSet<SettingsGroupModel> SettingsGroups { get; set; }
|
|
public DbSet<SettingsModel> Settings { get; set; }
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
{
|
|
modelBuilder.Entity<SettingsGroupModel>(sg =>
|
|
{
|
|
sg.ToTable("settings_groups");
|
|
sg.HasKey(x => x.Id);
|
|
});
|
|
|
|
modelBuilder.Entity<SettingsModel>(settingsEntity =>
|
|
{
|
|
settingsEntity.ToTable("settings");
|
|
settingsEntity.HasKey(x => x.Key);
|
|
});
|
|
|
|
base.OnModelCreating(modelBuilder);
|
|
}
|
|
} |