Closed lexon0011 closed 7 years ago
This may be because you don't have a connection string named IdentityDbContext
Sent from my iPhone
On Oct 5, 2016, at 11:20 AM, lexon0011 notifications@github.com wrote:
IdentityDbContext
No, because the following code works:
public IdentityAdminManagerService()
: base("IdentityDbContext")
{
}
But my goal is to write the following code:
public IdentityAdminManagerService(IDatabaseConfiguration databaseConfiguration)
: base(databaseConfiguration.ConnectionString)
{
}
The IDatabaseConfiguration was registered in my Unity container. As the IdentityServer3 use Autofac for Dependency Injection, my registered dependencies could not resolved.
You could use the dependency resolver overload like this:
var dbConfiguration = new DatabaseConfiguration(); // either resolve it using DI or create an isntance of IDatabaseConfiguration
IdentityAdminServiceFactory factory;
factory.IdentityAdminService = new Registration<IIdentityAdminService>(resolver=> new IdentityAdminManagerService(dbConfiguration));
Thank you, That was the answer I was looking for đź‘Ť
Please close this issue
I use Unity in my project to register and resolve dependency. To tell AutoFac how to resolve a custom dependency a write the following working code for my
IdentityServerServiceFactory
I couldn't resolve my custom dependency for the
IdentityAdminServiceFactory
, because theRegister
method has only a parameter for an optional string.I need a way to tell autofac, how it should resolve my dependencies, because in the
IdentityAdminManagerService
I need my IDatabaseConfiguration, which could not resolved at the moment:What is the correct way to resolve my dependency in the
Register
method ofIdentityAdminServiceFactory
??Thanks!