MVC Core 6 和 EF 6 数据库优先脚手架

MVC Core 6 and EF 6 Database First Scaffolding

我正在将项目从 .NET MVC5 EF6 迁移到 MVC 核心 6 EF6 项目。我一直在寻找有关如何从 SQlServer 数据库构建模型的指导。在这个 link 中,它在“包管理器控制台”中对 运行 这个命令说。

dotnet ef dbcontext scaffold "Server=vaio;Database=Company;Trusted_Connection=True;" 
Microsoft.EntityFrameworkCore.SqlServer -o Models

当我 运行 该命令(使用正确的连接字符串)时,我得到了错误

dotnet : Could not execute because the specified command or file was not found.

从我发现的其他参考资料来看,这个脚手架似乎可以工作,但所有参考资料都是针对旧版本的 .NET Core。在微软网站教程中,他们甚至声明...

This tutorial has not been updated for ASP.NET Core 6. The ASP.NET Core 6 web templates use the new minimal hosting model, which unifies Startup.cs and Program.cs into a single Program.cs file. Until this tutorial is updated, see Razor Pages with Entity Framework Core in ASP.NET Core - Tutorial 1 of 8 and Part 4, add a model to an ASP.NET Core MVC app on how to use EF with the new minimal hosting model. Updating the tutorial for ASP.NET Core 6 is tracked in this GitHub issue.

entity framework 是否有使用数据库优先模型的有效脚手架命令?

目前有什么好的参考资料material吗?

对于其他人来说,这是新的参考...

https://docs.microsoft.com/en-us/ef/core/cli/powershell#scaffold-dbcontext

错误来自于使用已弃用的函数。

Scaffold-DbContext 是新命令而不是 dotnet ef dbcontext scaffold

When I run that command (with my correct connection string), I get the error dotnet : Could not execute because the specified command or file was not found.

您是否在 运行 该命令之前安装了 Microsoft.EntityFrameworkCore.Tools 软件包?

dotnet ef dbcontext scaffold "Server=vaio;Database=Company;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -o Models

检查您的服务器地址。阅读 dotnet ef dbcontext scaffold 了解更多。