Upgraded packages. Improved startup. Removed unused components
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using MoonCore.Helpers;
|
||||
using MoonCore.Services;
|
||||
using Moonlight.ApiServer.Configuration;
|
||||
using Pomelo.EntityFrameworkCore.MySql.Infrastructure;
|
||||
|
||||
@@ -8,12 +6,13 @@ namespace Moonlight.ApiServer.Helpers;
|
||||
|
||||
public abstract class DatabaseContext : DbContext
|
||||
{
|
||||
private AppConfiguration? Configuration;
|
||||
public abstract string Prefix { get; }
|
||||
|
||||
private readonly AppConfiguration Configuration;
|
||||
|
||||
public DatabaseContext()
|
||||
public DatabaseContext(AppConfiguration configuration)
|
||||
{
|
||||
Configuration = ApplicationStateHelper.Configuration;
|
||||
Configuration = configuration;
|
||||
}
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
@@ -21,15 +20,6 @@ public abstract class DatabaseContext : DbContext
|
||||
if (optionsBuilder.IsConfigured)
|
||||
return;
|
||||
|
||||
// If no config service has been configured, we are probably
|
||||
// in a EF Core migration, so we need to construct the config manually
|
||||
if (Configuration == null)
|
||||
{
|
||||
Configuration = new ConfigService<AppConfiguration>(
|
||||
PathBuilder.File("storage", "app.json")
|
||||
).Get();
|
||||
}
|
||||
|
||||
var config = Configuration.Database;
|
||||
|
||||
var connectionString = $"host={config.Host};" +
|
||||
|
||||
Reference in New Issue
Block a user