![](/img/trans.png)
[英].NET 6 Identity Customization - Error: There is no implicit reference conversion from ApplicationUser to IdentityUser<string>
[英]There is no implicit reference conversion from ApplicationUser to IdentityUser
我正在尝试自定义一些使用泛型的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。 Microsoft.AspNetCore.Identity.EntityFrameworkCore.UserStore`8 [TUser,TRole,TContext,TKey,TUserClaim,TUserRole,TUserLogin,TUserToken]
1[System.Guid]', on
ApplicationUser1[System.Guid]', on
违反了类型参数'TUser'的约束
现在,当我转到UserStore的.NET实现(基类)时:
公共类UserStore <TUser,TRole,TContext,TKey>:UserStore <TUser,TRole,TContext,TKey,IdentityUserClaim <TKey>,IdentityUserRole <TKey>,IdentityUserLogin <TKey>,IdentityUserToken <TKey >>
其中TUser:IdentityUser <TKey>
... 其中TKey:IEquatable <TKey> {
我可以看到ApplicationUser继承自IdentityUser <GUID>。 满足此约束。 TKey是实现IEquatable <GUID>的GUID。 该约束也得到满足。
那是什么问题呢?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.