Reputation: 1608
I am migrating a project from a .NET MVC5 EF6 to a MVC core 6 EF6 project. I been hunting for some guidance on how to scaffold the model from the SQlServer database. In this link, it says to run this command in the "Package Manager Console".
dotnet ef dbcontext scaffold "Server=vaio;Database=Company;Trusted_Connection=True;"
Microsoft.EntityFrameworkCore.SqlServer -o Models
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.
From other references I have found, it appears that this scaffolding supposedly works, but all the references are for older versions of .NET Core. On the Microsoft website tutorial, they even state...
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.
Is there a working scaffolding command for entity framework using the database first model?
Is there any good reference material that is current?
Upvotes: 1
Views: 5577
Reputation: 1608
For anyone else looking, this is the new reference...
https://learn.microsoft.com/en-us/ef/core/cli/powershell#scaffold-dbcontext
The error came from using a deprecated function.
Scaffold-DbContext
is the new command instead of dotnet ef dbcontext scaffold
Upvotes: 1
Reputation: 9162
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.
Have you installed the Microsoft.EntityFrameworkCore.Tools
package before running that command?
dotnet ef dbcontext scaffold "Server=vaio;Database=Company;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -o Models
Check your server address. Read dotnet ef dbcontext scaffold to know more.
Upvotes: 0