ASP.Net核心身份在单独的类错误

问题描述:

我正在使用ASP.Net核心并尝试将某些身份组件移动到单独的程序集中。我将ApplicationDbContextApplicationUser转移到名为DataModels的程序集中。 (ApplicationUser处于DataModelsModels文件夹/命名空间。)ASP.Net核心身份在单独的类错误

在WebApplication的Startup.cs我引用此组件和一切编译罚款。我更新了AccountController以正确引用它。

当我开始了我的应用程序,我收到这样的:

处理此请求所需资源的编译过程中出现错误。请查看以下具体的错误细节并适当修改您的源代码。

类型或命名空间名称 'ApplicationUser' 找不到(是否缺少using指令或程序集引用?)

​​

我Startup.cs有这样的:

using DataModels.Models; 
... 
public void ConfigureServices(IServiceCollection services) 
{ 
    // Add framework services. 
    services.AddDbContext<DataModels.ApplicationDbContext>(options => 
     options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))); 

    services.AddIdentity<ApplicationUser, IdentityRole>() 
     .AddEntityFrameworkStores<DataModels.ApplicationDbContext>() 
     .AddDefaultTokenProviders(); 

    services.AddMvc(); 

    // Add application services. 
    services.AddTransient<IEmailSender, AuthMessageSender>(); 
    services.AddTransient<ISmsSender, AuthMessageSender>(); 
} 

很明显,我没有指定DataModels程序集,我只是不确定在哪里。

发现,这是在这些文件中提到:

_LoginPartial.cshtml 
Login.cshtml 

我需要更新与此这些文件:

@using DataModels.Models