![](/img/trans.png)
[英]404 error after scaffolding identity library of an ASP.NET Core 6 MVC project
[英]Adding Identity Scaffolding to ASP.NET Core MVC solution - getting error
错误:
找到 DBContext 类型“MvcMovieContext”,但它不继承自 Microsoft.ASPNetCore.Identity.EntityFrameworkCore.IdentityDBContext
我使用最新升级的 Visual Studio 2019 遵循的过程:安装了最新的相关和其他包(显示 Nuget 解决方案)
启动文件
using Microsoft.EntityFrameworkCore;
using MvcMovie.Data;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
public void ConfigureServices(IServiceCollection services)
{
services.AddControllersWithViews();
services.AddDbContext<MvcMovieContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("MvcMovieContext")));
}
指定身份脚手架模板后
保留 ~Views\Shared_Layout.cshtml 页面
数据库上下文 class 指定为 MvcMovie.Data.MvcMovieContext
没有文件被覆盖
没有指定用户 class
行
进程更新依赖
建立解决方案直到出错
我在这里和 github 回顾了类似的问题。我(新手)能找到的最接近的是UseSqlServer()
method is missing from Microsoft.EntityFrameworkCore.SqlServer
我查看了工作MvcMovie
解决方案的构建文件。 我已经更新了依赖项。 如果有人能告诉我如何解决DBContext
类型“不从 Microsoft.ASPNetCore.Identity.EntityFrameworkCore.IdentityDBContext 继承”的原因,那么我将非常感激。
正如@Matt U 在评论中所说,将DbContext
更改为IdentityDbContext
就可以了,包括
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
在context.cs
文件中。
我遇到了与往常一样的问题,我认为使用不同的数据库上下文进行身份验证是一种很好的做法,但我正在尝试通过 Azure 免费帐户来完成我的业务应用程序,而您只能获得 1 个数据库,因此我还需要使用我的主数据库进行身份验证。 所以从 IdentityDbContext 继承是我必须做的。
我研究了使用 Azure Active Directory 进行身份验证和条件访问,但对于只有 5 个用户的小公司来说,它看起来太复杂了。 实际上,身份验证非常简单,但创建和实施条件访问策略对于我的简单需求来说似乎过于复杂。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.