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:
@@ -11,22 +11,10 @@ namespace Content.Server.Database
|
||||
{
|
||||
public abstract class ServerDbContext : DbContext
|
||||
{
|
||||
/// <summary>
|
||||
/// The "dotnet ef" CLI tool uses the parameter-less constructor.
|
||||
/// When that happens we want to supply the <see cref="DbContextOptions"/> via <see cref="DbContext.OnConfiguring"/>.
|
||||
/// To use the context within the application, the options need to be passed the constructor instead.
|
||||
/// </summary>
|
||||
protected readonly bool InitializedWithOptions;
|
||||
|
||||
public ServerDbContext()
|
||||
protected ServerDbContext(DbContextOptions options) : base(options)
|
||||
{
|
||||
}
|
||||
|
||||
public ServerDbContext(DbContextOptions<ServerDbContext> options) : base(options)
|
||||
{
|
||||
InitializedWithOptions = true;
|
||||
}
|
||||
|
||||
public DbSet<Preference> Preference { get; set; } = null!;
|
||||
public DbSet<Profile> Profile { get; set; } = null!;
|
||||
public DbSet<AssignedUserId> AssignedUserId { get; set; } = null!;
|
||||
|
||||
Reference in New Issue
Block a user