需要在Startup.cs文件中添加Identity服务并在DbContext中包括IdentityUser。
在Startup.cs的ConfigureServices方法中添加以下代码:
services.AddDefaultIdentity()
.AddEntityFrameworkStores();
在DbContext类中继承IdentityDbContext
public class ApplicationDbContext : IdentityDbContext
{
public ApplicationDbContext(DbContextOptions options)
: base(options)
{
}
}
这样可以将IdentityUser添加到您的项目中。