Added a data context factory to abstract the database creation process

This commit is contained in:
tsommer committed 2022-08-17 21:00:37 +02:00
1 parent 12eecf9fe0
commit d53966501a
5 files changed
+34 -2

No files matched your search

@@ -2,7 +2,7 @@
namespace DataModel.Database.Common;
public sealed class DataContext : DbContext
public sealed class DataContext : DbContext, IDataContext
{
public DbSet<Setting> Settings { get; set; }
@@ -0,0 +1,11 @@
namespace DataModel.Database.Common;
public sealed class DataContextFactory
{
public IDataContext DataContext { get; private set; }
public void CreateDataContext(string path2Database)
{
this.DataContext = Setup.CreateDatabaseInstance(path2Database, true);
}
}
@@ -0,0 +1,14 @@
using Microsoft.EntityFrameworkCore;
namespace DataModel.Database.Common;
public interface IDataContext
{
public DbSet<Setting> Settings { get; set; }
public DbSet<Section> Sections { get; set; }
public DbSet<TextElement> TextElements { get; set; }
public DbSet<Translation> Translations { get; set; }
}