无法从基架创建新帐户



我正在尝试使用新的 .Net Core 2.1 中的新身份脚手架从头开始创建授权和身份验证,但不断收到此错误。

SqlException:对象名称"AspNetUsers"无效。

注册模型无法在此行上执行:

var result = await _userManager.CreateAsync(user, Input.Password);

身份托管启动.CS

[assembly: HostingStartup(typeof(Authorize.Areas.Identity.IdentityHostingStartup))]
namespace Authorize.Areas.Identity
{
public class IdentityHostingStartup : IHostingStartup
{
public void Configure(IWebHostBuilder builder)
{
builder.ConfigureServices((context, services) => {
services.AddDbContext<AuthorizeContext>(options =>
options.UseSqlServer(
context.Configuration.GetConnectionString("AuthorizeContextConnection")));
services.AddDefaultIdentity<AuthorizeUser>()
.AddEntityFrameworkStores<AuthorizeContext>()
.AddDefaultTokenProviders();
});
}
}
}

此错误通常表明您的数据库中没有 AspNetUsers 表。您是否运行了基架中提供的迁移?这可以通过电源外壳或控制台终端完成。导航到 Web 项目并执行Update-Database如果使用 Powershell 或控制台dotnet ef database update。 https://learn.microsoft.com/en-us/ef/core/managing-schemas/migrations/

最新更新