嘿,我试图将IRoleStore绑定到Rolestore,但我不断收到错误。我使用相同的代码应用程序用户和顺利,但作为例子,我将展示一个藏汉这里:依赖注入RoleStore与ninject
kernel.Bind<IRoleStore<ApplicationRole>>().To<RoleStore<ApplicationRole>>()
.WithConstructorArgument("context",
context => kernel.Get<InBuildingNavigatorDbContext>());
kernel.Bind<RoleManager<ApplicationRole>>().ToSelf().InRequestScope();
kernel.Bind<IUserStore<ApplicationUser>>().To<UserStore<ApplicationUser>>()
.WithConstructorArgument("context",
context => kernel.Get<InBuildingNavigatorDbContext>());
kernel.Bind<UserManager<ApplicationUser>>().ToSelf().InRequestScope();
而我得到的错误:
The type 'Microsoft.AspNet.Identity.EntityFramework.RoleStore<InBuildingNavigator.Data.Models.ApplicationRole>' cannot be used as type parameter 'TImplementation' in the generic type or method 'IBindingToSyntax<IRoleStore<ApplicationRole>>.To<TImplementation>()'. There is no implicit reference conversion from 'Microsoft.AspNet.Identity.EntityFramework.RoleStore<InBuildingNavigator.Data.Models.ApplicationRole>' to 'Microsoft.AspNet.Identity.IRoleStore<InBuildingNavigator.Data.Models.ApplicationRole>'.
有什么想法?
我尝试这样做,它确实是固定的错误,但我重做了整个角色的事情,所以它不再是相关的。但无论如何,它确实解决了它! :) –