IUserStore[Models.ApplicationUser] is not resolved by Unity Interface to Class, but resolved with InjectionConstructor

Viewed 3399

When I am trying to invoke Accounts controller, I am getting this error back,

[InvalidOperationException: The current type, Microsoft.AspNet.Identity.IUserStore`1[Proj1.Web.Models.ApplicationUser], is an interface and cannot be constructed. Are you missing a type mapping?]

But after searching through I got it working by ;

container.RegisterType<AccountController>(new InjectionConstructor());

But why this error in first place?

Account controller has a parameter less constructor ,

  public AccountController(ApplicationUserManager userManager, ApplicationSignInManager signInManager )
        {
            UserManager = userManager;
            SignInManager = signInManager;
        }

and then ApplicationUserManager has following parameter less constructor.

public ApplicationUserManager(IUserStore<ApplicationUser> store)
            : base(store)
        {
        }

So the dependency is IUserStore.

Now, as my standard practice , I would be doing something like following:

  container.RegisterType<IUserStore<ApplicationUser>,UserStore<ApplicationUser>>();

But instead we are doing , which kind of feels like magic

container.RegisterType<AccountController>(new InjectionConstructor());

What does above line means?

1 Answers
Related