Projekte können erstellt und geladen werden
This commit is contained in:
@@ -18,24 +18,28 @@ namespace SewerStammGen.HostBuilders
|
||||
{
|
||||
hostBuilder.ConfigureServices((context, services) =>
|
||||
{
|
||||
string connectionString = "";
|
||||
Action<DbContextOptionsBuilder> configureDbContext = null;
|
||||
string databaseToUse = context.Configuration.GetConnectionString("databaseToUse");
|
||||
Trace.WriteLine(databaseToUse);
|
||||
if (databaseToUse.Equals("default"))
|
||||
string? connectionString = "";
|
||||
Action<DbContextOptionsBuilder>? configureDbContext = null;
|
||||
string? databaseToUse = context.Configuration.GetConnectionString("databaseToUse");
|
||||
if (databaseToUse != null)
|
||||
{
|
||||
connectionString = context.Configuration.GetConnectionString("default");
|
||||
configureDbContext = o => o.UseNpgsql(connectionString);
|
||||
}
|
||||
else if (databaseToUse.Equals("sqlite"))
|
||||
{
|
||||
connectionString = context.Configuration.GetConnectionString("sqlite");
|
||||
configureDbContext = o => o.UseSqlite(connectionString);
|
||||
|
||||
if (databaseToUse.Equals("default"))
|
||||
{
|
||||
connectionString = context.Configuration.GetConnectionString("default");
|
||||
configureDbContext = o => o.UseNpgsql(connectionString);
|
||||
}
|
||||
else if (databaseToUse.Equals("sqlite"))
|
||||
{
|
||||
connectionString = context.Configuration.GetConnectionString("sqlite");
|
||||
configureDbContext = o => o.UseSqlite(connectionString);
|
||||
}
|
||||
services.AddDbContext<SewerStammGenDbContext>(configureDbContext);
|
||||
services.AddSingleton<SewerStammGenDbContextFactory>(new SewerStammGenDbContextFactory(configureDbContext));
|
||||
}
|
||||
|
||||
|
||||
services.AddDbContext<SewerStammGenDbContext>(configureDbContext);
|
||||
services.AddSingleton<SewerStammGenDbContextFactory>(new SewerStammGenDbContextFactory(configureDbContext));
|
||||
|
||||
});
|
||||
return hostBuilder;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user