Asp.net core 使用从IdentityUser继承的自定义用户类时出错
我正在使用asp.net core 2.2。 为从IdentityUser继承的应用程序用户使用自定义类时,注册和密码登录失败,并显示消息“SqlException:无效列名'ApplicationUserId' Statrup.csAsp.net core 使用从IdentityUser继承的自定义用户类时出错,asp.net-core,asp.net-identity,basic-authentication,Asp.net Core,Asp.net Identity,Basic Authentication,我正在使用asp.net core 2.2。 为从IdentityUser继承的应用程序用户使用自定义类时,注册和密码登录失败,并显示消息“SqlException:无效列名'ApplicationUserId' Statrup.cs services.AddIdentity<ApplicationUser, IdentityRole>() .AddEntityFrameworkStores<ApplicationDbContext>()
services.AddIdentity<ApplicationUser, IdentityRole>()
.AddEntityFrameworkStores<ApplicationDbContext>()
.AddDefaultTokenProviders();
public class ApplicationUser : IdentityUser
{
}
数据库是生成的标准标识,没有添加自定义列
尝试如下修改应用程序的bContext:
public类ApplicationDbContext:IdentityDbContext
{
公共应用程序DBContext(DbContextOptions选项):基本(选项)
{
}
}
默认的ApplicationDbContext使用
IdentityUser
作为其用户存储,而不是ApplicationUser
是否运行迁移和更新数据库以同步模型和数据库?是否有任何详细步骤重现您的问题?对于错误消息,您使用了.net core 2.0 identity中的AccountController
。对于.net core 2.2,默认标识是带有LoginModel
的库。您是否已从.net core 2.0迁移到.net core 2.2?