没有从ApplicationUser到IdentityUser的隐式引用转换
本文关键字:引用 转换 IdentityUser ApplicationUser | 更新日期: 2023-09-27 17:54:31
我正在尝试自定义一些ASP。. NET Identity使用泛型的核心类。
我的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]', on
Microsoft.AspNetCore.Identity.EntityFrameworkCore.UserStore ' 8[TUser,TRole,TContext,TKey,TUserClaim,TUserRole,TUserLogin,TUserToken]'违反类型参数'TUser'的约束
现在,当我去到。net实现的UserStore(基类):
公共类UserStore<TUser,>:TUser, TRole, TContext, TKey,IdentityUserClaim<TKey>,>IdentityUserLogin<TKey>>在
where TUser: IdentityUser
… where TKey: equatable{
我可以看到ApplicationUser继承自IdentityUser
那么问题是什么呢?
添加GUID到
IdentityBuilder.AddEntityFrameworkStores<ApplicationDbContext,Guid>();