Added data context
This commit is contained in:
2 files changed
+42
No files matched your search
@@ -0,0 +1,28 @@
|
||||
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
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user