Asp.net mvc 5 RoleStore对StructureMap抛出错误

Asp.net mvc 5 RoleStore对StructureMap抛出错误,asp.net-mvc-5,asp.net-identity,structuremap,user-roles,Asp.net Mvc 5,Asp.net Identity,Structuremap,User Roles,当我尝试使用Asp.Net Identity RoleStore并将StructureMap用作DI容器时,UserStore工作正常,但RoleStore在编译时出错 //works fine cfg.For<IUserStore<ApplicationUser>>().Use<UserStore<ApplicationUser>>(); //does NOT work cfg.For<IRoleStore<IdentityRole

当我尝试使用Asp.Net Identity RoleStore并将StructureMap用作DI容器时,UserStore工作正常,但RoleStore在编译时出错

//works fine
cfg.For<IUserStore<ApplicationUser>>().Use<UserStore<ApplicationUser>>();

//does NOT work
cfg.For<IRoleStore<IdentityRole>>().Use<RoleStore<IdentityRole>>(); 
//很好用
cfg.For().Use();
//不起作用
cfg.For().Use();
抛出以下错误

类型 'Microsoft.AspNet.Identity.EntityFramework.RoleStore' 不能用作泛型类型中的类型参数“TConcreteType” 或方法 'StructureMap.Configuration.DSL.Expressions.CreatePluginFamilyExpression.Use()'。 不存在来自的隐式引用转换 'Microsoft.AspNet.Identity.EntityFramework.RoleStore' 到 “Microsoft.AspNet.Identity.IRoleStore”

因为
RoleStore
不是从
IRoleStore
实现的。实际上,它是从
IRoleStore
实现的。因此,请尝试以下方法:

cfg.For<IRoleStore<IdentityRole,string>>().Use<RoleStore<IdentityRole>>(); 
cfg.For().Use();