mirror of
https://github.com/space-wizards/space-station-14.git
synced 2026-02-15 03:31:30 +01:00
Fix DbContext configuration nightmares.
Thanks to julian figuring out IDesignTimeDbContextFactory exists in #6327. All this DbContext configuration and options setup stuff is insane. Microsoft should be absolutely ashamed for coming up with this load of garbage.
This commit is contained in:
@@ -8,21 +8,17 @@ namespace Content.Server.Database
|
||||
{
|
||||
public sealed class PostgresServerDbContext : ServerDbContext
|
||||
{
|
||||
// This is used by the "dotnet ef" CLI tool.
|
||||
public PostgresServerDbContext()
|
||||
{
|
||||
}
|
||||
|
||||
static PostgresServerDbContext()
|
||||
{
|
||||
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
|
||||
}
|
||||
|
||||
public PostgresServerDbContext(DbContextOptions<PostgresServerDbContext> options) : base(options)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder options)
|
||||
{
|
||||
if (!InitializedWithOptions)
|
||||
options.UseNpgsql("dummy connection string");
|
||||
|
||||
options.ReplaceService<IRelationalTypeMappingSource, CustomNpgsqlTypeMappingSource>();
|
||||
|
||||
((IDbContextOptionsBuilderInfrastructure) options).AddOrUpdateExtension(new SnakeCaseExtension());
|
||||
@@ -41,10 +37,6 @@ namespace Content.Server.Database
|
||||
#endif
|
||||
}
|
||||
|
||||
public PostgresServerDbContext(DbContextOptions<ServerDbContext> options) : base(options)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
base.OnModelCreating(modelBuilder);
|
||||
|
||||
Reference in New Issue
Block a user