I'm using Simple Injector in my MVC application error and I receive the below error:
The constructor of type ApplicationUserManager contains the parameter with name 'store' and type IUserStore that is not registered. Please ensure IUserStore is registered, or change the constructor of ApplicationUserManager.
It wants me to register the UserStore
, I think I have to register it to the UserManager
but I'm unsure what to do.
I thought it was supposed to look like this:
private static void InitializeContainer(Container container)
{
container.Register<IAuthorisationManager, AuthorisationManager>();
container.Register<IAuthorisationRepository, AuthorisationRepository>();
container.Register<IUserStore<ApplicationUser>, UserStore<ApplicationUser>>();
}
Identity Config:
public class ApplicationUserManager : UserManager<ApplicationUser>
{
public ApplicationUserManager(IUserStore<ApplicationUser> store) : base(store) { }
}
But I then receive the error:
For the container to be able to create
UserStore<ApplicationUser>
it should have only one public constructor: it has 2. See https://simpleinjector.org/one-constructor for more information.
But it's default ASP.NET code so I can't/won't change it.
Can anyone explain this error and tell me how to fix it please?
container.Register<IUserStore<ApplicationUser>>(() => new UserStore<ApplicationUser>());
Needed to register the user store but it has multiple constructors so you need to add the above line