Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-core/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net core 使用从IdentityUser继承的自定义用户类时出错_Asp.net Core_Asp.net Identity_Basic Authentication - Fatal编程技术网

Asp.net core 使用从IdentityUser继承的自定义用户类时出错

Asp.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>()

我正在使用asp.net core 2.2。 为从IdentityUser继承的应用程序用户使用自定义类时,注册和密码登录失败,并显示消息“SqlException:无效列名'ApplicationUserId'

Statrup.cs

 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?