From 19b9851832c6b4bc1bed8a74243f138c631b1e6e Mon Sep 17 00:00:00 2001 From: Thorsten Sommer Date: Sun, 12 Jun 2022 17:15:30 +0200 Subject: [PATCH] Added data context --- I18N Commander/DataModel/DataModel.csproj | 14 ++++++++++ .../DataModel/Database/Common/DataContext.cs | 28 +++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 I18N Commander/DataModel/Database/Common/DataContext.cs diff --git a/I18N Commander/DataModel/DataModel.csproj b/I18N Commander/DataModel/DataModel.csproj index 40c60dd..07d4dfb 100644 --- a/I18N Commander/DataModel/DataModel.csproj +++ b/I18N Commander/DataModel/DataModel.csproj @@ -7,4 +7,18 @@ enable + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + diff --git a/I18N Commander/DataModel/Database/Common/DataContext.cs b/I18N Commander/DataModel/Database/Common/DataContext.cs new file mode 100644 index 0000000..43d1c5d --- /dev/null +++ b/I18N Commander/DataModel/Database/Common/DataContext.cs @@ -0,0 +1,28 @@ +using Microsoft.EntityFrameworkCore; + +namespace DataModel.Database.Common; + +public sealed class DataContext : DbContext +{ + public DbSet? Settings { get; set; } + + public DataContext(DbContextOptions contextOptions) : base(contextOptions) + { + } + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + base.OnModelCreating(modelBuilder); + + #region Ideas + + modelBuilder.Entity().HasIndex(n => n.Id); + modelBuilder.Entity().HasIndex(n => n.Name).IsUnique(); + modelBuilder.Entity().HasIndex(n => n.BoolValue); + modelBuilder.Entity().HasIndex(n => n.GuidValue); + modelBuilder.Entity().HasIndex(n => n.IntegerValue); + modelBuilder.Entity().HasIndex(n => n.TextValue); + + #endregion + } +} \ No newline at end of file