In EFCore 2.0 Add new feature, DbContext pooling. i know how to use it in single context, however, sometimes need multi context in project,
public class BContext
Or you can register your own factory of DbContextPool
services.AddDbContextPool<AContext>(options =>
{
options.UseInMemoryDatabase("AContext.InMemory");
});
services.AddDbContextPool<BContext>(options =>
{
options.UseInMemoryDatabase("BContext.InMemory");
});
collection.AddSingleton(svcs => new DbContextPool<AContext>(svcs.GetService<DbContextOptions<AContext>>()));
collection.AddSingleton(svcs => new DbContextPool<BContext>(svcs.GetService<DbContextOptions<BContext>>()));
Ok. i've found problem. You need to download EF Core, then change constructor for DbContextPool< TContext>
original
public DbContextPool([NotNull] DbContextOptions options)
and change to
public DbContextPool([NotNull] DbContextOptions<TContext> options)
otherwise DI will use last added options :)