我在
中的下一个代码中有错误public void ConfigureServices(IServiceCollection services)
services.AddIdentity<ApsUser, ApsRole>(option =>
{
option.Password.RequiredLength = 6;
})
GenericArguments [0],'project.Core.Users.ApsUser','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
}
如何解决错误?
答案 0 :(得分:0)
临时我做了这个
用户和角色
public class ApsUser : IdentityUser<int>, IEntity
公共类ApsRole:IdentityRole,IEntityLog
startup.cs
services.AddIdentity(option =&gt; { option.Password.RequiredLength = 6; option.Password.RequireLowercase = false; option.Password.RequireNonAlphanumeric = false; option.Password.RequireUppercase = false; option.Password.RequireNonAlphanumeric = false;
})
.AddEntityFrameworkStores<ApContext, int>()
.AddDefaultTokenProviders();