You've already forked Extensions.Configuration.EntityFrameworkCore
Don't use PooledDbContextFactory when initially loading config
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
namespace RAIC.Extensions.Configuration.EntityFrameworkCore.Extensions;
|
||||
@@ -21,13 +20,13 @@ public static class ConfigurationBuilderExtensions
|
||||
/// </param>
|
||||
/// <returns>The <see cref="IConfigurationBuilder"/></returns>
|
||||
public static IConfigurationBuilder AddDbSet<TDbContext, TSetting>(this IConfigurationBuilder builder, DbContextOptionsTransformer<TDbContext> optionsTransformer)
|
||||
where TDbContext : DbContext, ISettingsDbContext<DbSet<TSetting>, TSetting>
|
||||
where TDbContext : DbContext, ISettingsDbContext<DbSet<TSetting>, TSetting>, ISettingsDbContextFactory<TDbContext>
|
||||
where TSetting : class, ISetting
|
||||
{
|
||||
// DEBT: Find way to create non-pooled DbContextFactory since this is only a short lived usage
|
||||
var options = optionsTransformer(new DbContextOptionsBuilder<TDbContext>()).Options;
|
||||
var configurationSource = new EntityFrameworkCoreDbSetConfigurationSource<TDbContext, TSetting>()
|
||||
{
|
||||
DbContextFactory = new PooledDbContextFactory<TDbContext>(optionsTransformer(new DbContextOptionsBuilder<TDbContext>()).Options, poolSize: 1)
|
||||
DbContextFactory = () => TDbContext.Create(options)
|
||||
};
|
||||
|
||||
return builder.Add(configurationSource);
|
||||
|
||||
Reference in New Issue
Block a user