[CHANGE] Preparing database
This commit is contained in:
31
Manager.Data/Contexts/ApplicationDbContext.cs
Normal file
31
Manager.Data/Contexts/ApplicationDbContext.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user