当使用ASP.NET Identity时,如果你想在非字符串用户ID上使用UserManager和UserStore,你需要进行一些额外的配置。下面是解决这个问题的步骤和代码示例:
public class ApplicationUser : IdentityUser
{
// 其他属性
}
services.AddIdentity>()
.AddEntityFrameworkStores()
.AddDefaultTokenProviders();
public class ApplicationDbContext : IdentityDbContext, int>
{
// 数据库上下文的代码
}
var userManager = new UserManager(new UserStore, int>(context));
注意:你还需要根据你的具体需求对其他代码进行相应的更改和调整。
这样,你就可以在非字符串用户ID上使用ASP.NET Identity的UserManager和UserStore了。