Schlauchliner erweitert
This commit is contained in:
@@ -19,19 +19,27 @@ namespace DaSaSo.Wpf.HostBuilders
|
||||
host.ConfigureServices((context,services) =>
|
||||
{
|
||||
string connectionString = "";
|
||||
Action<DbContextOptionsBuilder> configureDbContext = null;
|
||||
Action<DbContextOptionsBuilder> configureDbContext;
|
||||
string databaseToUse = context.Configuration.GetConnectionString("databaseToUse");
|
||||
Trace.WriteLine(databaseToUse);
|
||||
if(databaseToUse.Equals("default"))
|
||||
{
|
||||
connectionString = context.Configuration.GetConnectionString("default");
|
||||
configureDbContext = o => o.UseNpgsql(connectionString);
|
||||
configureDbContext = o =>
|
||||
{
|
||||
o.UseNpgsql(connectionString);
|
||||
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
|
||||
};
|
||||
}
|
||||
else if(databaseToUse.Equals("sqlite"))
|
||||
{
|
||||
connectionString = context.Configuration.GetConnectionString("sqlite");
|
||||
configureDbContext = o => o.UseSqlite(connectionString);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotImplementedException("Database Type not implementent" + databaseToUse);
|
||||
}
|
||||
|
||||
|
||||
services.AddDbContext<DaSaSoDbContext>(configureDbContext);
|
||||
|
||||
Reference in New Issue
Block a user