[英]There is no implicit reference conversion from ApplicationUser to IdentityUser
I am trying to customize some ASP.NET Identity Core classes which use Generics. 我正在尝试自定义一些使用泛型的ASP.NET Identity Core类。
My ApplicationUser class: 我的ApplicationUser类:
public class ApplicationUser : IdentityUser<Guid>//, ApplicationUserClaim, ApplicationRole, ApplicationUserLogin>
{
public ApplicationUser() { }
}
My ApplicationUserStore class: 我的ApplicationUserStore类:
public class ApplicationUserStore : UserStore<ApplicationUser, ApplicationRole, ApplicationDbContext, Guid>
{
public ApplicationUserStore(ApplicationDbContext ctx, IdentityErrorDescriber describer = null) : base(ctx, describer)
{
}
}
Error message is: 错误信息是:
'AspDotNetCoreFullFramework.Identity.
“AspDotNetCoreFullFramework.Identity。 ApplicationUser
1[System.Guid]', on
Microsoft.AspNetCore.Identity.EntityFrameworkCore.UserStore`8[TUser,TRole,TContext,TKey,TUserClaim,TUserRole,TUserLogin,TUserToken]' violates the constraint of type parameter 'TUser'Microsoft.AspNetCore.Identity.EntityFrameworkCore.UserStore`8 [TUser,TRole,TContext,TKey,TUserClaim,TUserRole,TUserLogin,TUserToken]
1[System.Guid]', on
ApplicationUser1[System.Guid]', on
违反了类型参数'TUser'的约束
Now, when I go to the .NET implementation of UserStore (Base class): 现在,当我转到UserStore的.NET实现(基类)时:
public class UserStore<TUser, TRole, TContext, TKey> : UserStore<TUser, TRole, TContext, TKey, IdentityUserClaim<TKey>, IdentityUserRole<TKey>, IdentityUserLogin<TKey>, IdentityUserToken<TKey>>
公共类UserStore <TUser,TRole,TContext,TKey>:UserStore <TUser,TRole,TContext,TKey,IdentityUserClaim <TKey>,IdentityUserRole <TKey>,IdentityUserLogin <TKey>,IdentityUserToken <TKey >>
where TUser : IdentityUser<TKey>其中TUser:IdentityUser <TKey>
... where TKey : IEquatable<TKey> {... 其中TKey:IEquatable <TKey> {
I can see that ApplicationUser inherits from IdentityUser<GUID>. 我可以看到ApplicationUser继承自IdentityUser <GUID>。 This constraint is fulfilled.
满足此约束。 TKey is GUID which implements IEquatable<GUID>.
TKey是实现IEquatable <GUID>的GUID。 This constraint is also fulfilled.
该约束也得到满足。
So what is the problem? 那是什么问题呢?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.