Fixing database configuration

There is still broken dependencies when the module is in another assembly
This commit is contained in:
Zoe Roux
2021-05-04 17:59:05 +02:00
parent 709e12191d
commit feb643da2e
10 changed files with 120 additions and 68 deletions
+11 -3
View File
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using Kyoo.Controllers;
using Microsoft.AspNetCore.Hosting;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
@@ -59,9 +60,16 @@ namespace Kyoo.Postgresql
/// <inheritdoc />
public void Configure(IServiceCollection services, ICollection<Type> availableTypes)
{
services.AddScoped<DatabaseContext>(_ => new PostgresContext(
_configuration.GetDatabaseConnection("postgres"),
_environment.IsDevelopment()));
services.AddDbContext<DatabaseContext, PostgresContext>(x =>
{
x.UseNpgsql(_configuration.GetDatabaseConnection("postgres"));
if (_environment.IsDevelopment())
x.EnableDetailedErrors().EnableSensitiveDataLogging();
});
// services.AddScoped<DatabaseContext>(_ => new PostgresContext(
// _configuration.GetDatabaseConnection("postgres"),
// _environment.IsDevelopment()));
// services.AddScoped<DbContext>(x => x.GetRequiredService<PostgresContext>());
}
}
}