![](/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.