问题描述
我想做的是以下事情:
使用Identity Core(主键为Int)设置登录/注销.我遵循了ASP.NET Core文档中的以下文章:配置身份主键数据类型. (他们使用GUID,但想法是相同的).设置非常成功,ID为整数,并且正在填充数据库.
Setup login/logout using Identity Core, with the Primary Key as Int. I followed the following article in the ASP.NET Core Documentation: Configure Identity primary keys data type. (They use GUID's but the idea is the same).The setup is quite succesfull, the ID's are integers and the database is getting populated.
但是,当我尝试使用内置的SignInManager<ApplicationUser>
登录并调用方法
However, when I try to sign in using the built-in SignInManager<ApplicationUser>
and invoking the the method
var result = await _signInManager.PasswordSignInAsync(Username,Password, RememberMe, lockoutOnFailure: false);
我收到以下错误:
我确定SecurityTimeStamp已满,并且服务已添加到Startup.cs中
I'm sure the SecurityTimeStamp is filled up and the services are added in the Startup.cs
services.AddIdentity<ApplicationUser, ApplicationRole>()
.AddEntityFrameworkStores<ApplicationDbContext, int>()
.AddDefaultTokenProviders();
我的课程:
ApplicationUser
ApplicationUser
public class ApplicationUser : IdentityUser<int>
{
}
ApplicationRole
ApplicationRole
public class ApplicationRole : IdentityRole<int>
{
}
ApplicationDbContext
ApplicationDbContext
public class ApplicationDbContext : IdentityDbContext<ApplicationUser, ApplicationRole, int>
{
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
: base(options)
{
}
}
Stacktrace
Stacktrace
推荐答案
删除并重新创建数据库...非常明显.
Dropped and recreated the database ... pretty obvious.
//已解决.
这篇关于身份核心主键为Int,无法使用SignInManager的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!