Question

I just upgraded the ASP.NET Identity Entity Framework package from 1.0 to 2.0 and one of the Ninject bindings is now broken:

kernel.Bind<IUserStore<User>>().To<UserStore<User>>();
kernel.Bind<UserManager<User>>().ToSelf();
kernel.Bind<IRoleStore<IdentityRole>>().To<RoleStore<IdentityRole>>();
kernel.Bind<RoleManager<IdentityRole>>().ToSelf();

The second last one is giving this error on compile:

The type 'Microsoft.AspNet.Identity.EntityFramework.RoleStore' cannot be used as type parameter 'TImplementation' in the generic type or method 'Ninject.Syntax.IBindingToSyntax.To()'.

There is no implicit reference conversion from 'Microsoft.AspNet.Identity.EntityFramework.RoleStore' to 'Microsoft.AspNet.Identity.IRoleStore'.

These are some of the declarations of the classes involved:

public interface IRoleStore<TRole> : IRoleStore<TRole, string>, IDisposable where TRole : IRole<string>

public class RoleStore<TRole, TKey, TUserRole> : IQueryableRoleStore<TRole, TKey>, IRoleStore<TRole, TKey>, IDisposable where TRole : IdentityRole<TKey, TUserRole>, new() where TUserRole : IdentityUserRole<TKey>, new()

I'm not sure what has caused it to break?

Was it helpful?

Solution

We added a new base RoleStore class and added the user role entity type as a generic type, so perhaps try

kernel.Bind<IRoleStore<IdentityRole, string>>().To<RoleStore<IdentityRole, string, IdentityUserRole>>();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top