【发布时间】:2017-07-11 09:15:25
【问题描述】:
我在下一个代码中有错误
public void ConfigureServices(IServiceCollection services)
services.AddIdentity<ApsUser, ApsRole>(option =>
{
option.Password.RequiredLength = 6;
})
GenericArguments[0], 'project.Core.Users.ApsUser', on 'Microsoft.AspNetCore.Identity.EntityFrameworkCore.UserStore`9[TUser,TRole,TContext,TKey,TUserClaim,TUserRole,TUserLogin,TUserToken,TRoleClaim] '违反了类型参数'TUser'的约束。
我的班级
public class ApsUser : IdentityUser<int, UserClaim, UserRole, UserLogin>, IEntity
{
public UserState State { get; set; }
#region IEntityLogFields
#endregion
}
public class UserRole : IdentityUserRole<int>, IEntity<int>
{
public int Id { get; set; }
#region IEntityLogFields
#endregion
}
如何修复错误?
【问题讨论】:
-
能否展示一下 ApsRole 和 ApsUser 的实现?
-
我编辑了第一条消息
-
ApsUser继承自IdentityUser<int, UserClaim, UserRole, UserLogin>, IEntity背后的原因是什么?ApsUser : IdentityUser还不够吗? -
你能像
ApsUser : IdentityUser和services.AddIdentity<ApsUser, IdentityRole>(option => { option.Password.RequiredLength = 6; })一样继承吗?不要仅仅为了测试而使用ApsRole。 -
必须是 IdentityUser
标签: c# asp.net-core asp.net-core-identity