【发布时间】:2016-07-03 18:00:05
【问题描述】:
我正在尝试自定义一些使用泛型的 ASP.NET Identity Core 类。
我的 ApplicationUser 类:
public class ApplicationUser : IdentityUser<Guid>//, ApplicationUserClaim, ApplicationRole, ApplicationUserLogin>
{
public ApplicationUser() { }
}
我的 ApplicationUserStore 类:
public class ApplicationUserStore : UserStore<ApplicationUser, ApplicationRole, ApplicationDbContext, Guid>
{
public ApplicationUserStore(ApplicationDbContext ctx, IdentityErrorDescriber describer = null) : base(ctx, describer)
{
}
}
错误信息是:
'AspDotNetCoreFullFramework.Identity.ApplicationUser
1[System.Guid]', onMicrosoft.AspNetCore.Identity.EntityFrameworkCore.UserStore`8[TUser,TRole,TContext,TKey,TUserClaim,TUserRole,TUserLogin,TUserToken]' 违反类型参数'TUser'的约束
现在,当我转到 UserStore(基类)的 .NET 实现时:
公共类 UserStore
: UserStore , IdentityUserRole , IdentityUserLogin , IdentityUserToken >
其中 TUser : IdentityUser
... 其中 TKey : IEquatable{
我可以看到 ApplicationUser 继承自 IdentityUser
那么问题出在哪里?
【问题讨论】:
-
或者指向我关于这个问题的参考..
-
您在身份方面到底想要做什么,您能否更详细地解释一下。我认为这可能有助于其他人指出您采取不同的方法..跨度>
-
我只想实现 ASP.NET Identity API 尽可能可定制,以便将其用作未来项目的模板。稍后我可以看看它,无需太多探索。
标签: c# generics entity-framework-6 asp.net-identity entity-framework-core