If I understand the question correctly you can't inject IDbContext into your class as you sometimes need AdminDbContext and sometimes AppDbContext within the same class, so you can't write the Ninject binding.
In this case you can write an IDbContextFactory interface and inject that.
public interface IDbContextFactory
{
IDbContext CreateAdminContext();
IDbContext CreateAppContext();
}
public class DbContextFactory : IDbContextFactory
{
//implementation of above interface methods to return the relevant context.
}
Then your class can inject that instead of the context
public class YourClass
{
private readonly IDbContextFactory _factory;
public YourClass(IDbContextFactory factory)
{
_factory = factory;
}
public YourAdminMethod()
{
using (var context = _factory.CreateAdminContext())
{
//do stuff
}
}
public YourAppMethod()
{
using (var context = _factory.CreateAppContext())
{
//do stuff
}
}
}
and then you just need one binding in your Ninject bindings for IDbContextFactory, which can be singleton.
kernel.Bind<IDbContextFactory>().To<DbContextFactory>().InSingletonScope();
AdminDbContextandAppDbContextdirectly...