I'm new to Unity and Identity, and I changed my implementation of Identity 2 to use int Keys instead of strings. I followed this article . It works great at this point. However, I use Unity for IoC, and it works great with my repositories, however I struggle to make it work with personality. I went over this article to switch.
I saw similar questions, but they all used string keys, so I guess I have something funky since I use int.
The problem is in the ctor of the ApplicationUserStore class:
public class ApplicationUserStore : UserStore<ApplicationUser, ApplicationRole, int, ApplicationUserLogin, ApplicationUserRole, ApplicationUserClaim>, IUserStore<ApplicationUser, int>, IDisposable { public ApplicationUserStore(IdentityDb context) : base(context) { } }
Here is IdentityDb.cs :
public class IdentityDb : IdentityDbContext<ApplicationUser, ApplicationRole, int, ApplicationUserLogin, ApplicationUserRole, ApplicationUserClaim> { public IdentityDb() : base("DefaultConnection") { } static IdentityDb() {
And here is the relevant part of UnityConfig.cs :
container.RegisterType<IdentityDb>(new PerResolveLifetimeManager()); container.RegisterType<ApplicationSignInManager>(); container.RegisterType<ApplicationUserManager>(); container.RegisterType<ApplicationRoleManager>(); container.RegisterType<IAuthenticationManager>( new InjectionFactory(c=>HttpContext.Current.GetOwinContext().Authentication)); container.RegisterType<IUserStore<ApplicationUser, int>, ApplicationUserStore>( new InjectionConstructor(typeof(IdentityDb)));
When I try to start the application, the context parameter in ctor ApplicationUserStore is null .
I would appreciate any help that could be offered.
Thanks!