You've already forked Extensions.Configuration.EntityFrameworkCore
Remove unnecessary TSetting type parameter from ISettingsDbContext & just use ISetting instead
This commit is contained in:
@@ -33,7 +33,7 @@ public record Setting : ISetting
|
||||
public required string Value { get; set; }
|
||||
}
|
||||
|
||||
public class MyDbContext(DbContextOptions<MyDbContext> options) : DbContext(options), ISettingsDbContext<DbSet<Setting>, Setting>, ISettingsDbContextFactory<MyDbContext>
|
||||
public class MyDbContext(DbContextOptions<MyDbContext> options) : DbContext(options), ISettingsDbContext<DbSet<Setting>>, ISettingsDbContextFactory<MyDbContext>
|
||||
{
|
||||
public DbSet<Setting> Settings { get; set; }
|
||||
|
||||
@@ -44,10 +44,11 @@ var builder = Host.CreateApplicationBuilder(args) // or WebApplication.CreateB
|
||||
|
||||
// build an initial configuration
|
||||
builder.Configuration.AddJsonFile("appsettings.json")
|
||||
...
|
||||
.AddUserSecrets<Program>(); // or whereever your connection string lives
|
||||
|
||||
// obtain connection string from preliminary config so can initialise other settings from DbSet
|
||||
builder.Configuration.AddDbSet<MyDbContext, Setting>(dbContextOptions => dbContextOptions.UseNpgsql(builder.Configuration.GetConnectionString("Default")));
|
||||
// obtain connection string from preliminary config so can initialise other settings from DbContext
|
||||
builder.Configuration.AddDbContext<MyDbContext>(dbContextOptions => dbContextOptions.UseNpgsql(builder.Configuration.GetConnectionString("Default")));
|
||||
|
||||
...
|
||||
|
||||
|
||||
Reference in New Issue
Block a user