I18NCommander/I18N Commander/DataModel/Database/Common/DataContext.cs

28 lines
896 B
C#
Raw Normal View History

2022-06-12 15:15:30 +00:00
using Microsoft.EntityFrameworkCore;
namespace DataModel.Database.Common;
public sealed class DataContext : DbContext
{
public DbSet<Setting>? Settings { get; set; }
public DataContext(DbContextOptions<DataContext> contextOptions) : base(contextOptions)
{
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
#region Ideas
modelBuilder.Entity<Setting>().HasIndex(n => n.Id);
modelBuilder.Entity<Setting>().HasIndex(n => n.Name).IsUnique();
modelBuilder.Entity<Setting>().HasIndex(n => n.BoolValue);
modelBuilder.Entity<Setting>().HasIndex(n => n.GuidValue);
modelBuilder.Entity<Setting>().HasIndex(n => n.IntegerValue);
modelBuilder.Entity<Setting>().HasIndex(n => n.TextValue);
#endregion
}
}