Referenzen entfernt
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using SewerStammGen.EntityFramework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
@@ -14,38 +13,6 @@ namespace SewerStammGen.HostBuilders
|
||||
{
|
||||
static class AddDBContextHostBuilderExtensions
|
||||
{
|
||||
public static IHostBuilder AddDBContext(this IHostBuilder hostBuilder)
|
||||
{
|
||||
hostBuilder.ConfigureServices((context, services) =>
|
||||
{
|
||||
string? connectionString = "";
|
||||
Action<DbContextOptionsBuilder>? configureDbContext = null;
|
||||
string? databaseToUse = context.Configuration.GetConnectionString("databaseToUse");
|
||||
if (databaseToUse != null)
|
||||
{
|
||||
|
||||
if (databaseToUse.Equals("default"))
|
||||
{
|
||||
connectionString = context.Configuration.GetConnectionString("default");
|
||||
configureDbContext = o =>
|
||||
{
|
||||
o.EnableSensitiveDataLogging();
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
|
||||
});
|
||||
return hostBuilder;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user