I'm using it in all my new projects since a while and I find it much more powerful than raw command line, and it allows you to save your execution settings (which will avoid you to create a. 56 minutes to read 18 contributors Feedback In this article Prerequisites Create the web app project Set up the site style The data model The Student entity The Enrollment entity The Course entity Scaffold Student pages Database connection string Update the database context class Program. a database is via the command: Scaffold-DbContext. I'm glad to see that post is still helpful as it receives some new upvotes, but instead of command-line scaffolding, there's a newer solution for the happy users of VS : you can rely on the retro-engineering feature of the extension EF Core Power tools. dotnet ef dbcontext scaffold Serverlocalhost Userroot Passwordyourpassword Databasemydb -c DBContext -o Models Serverlocalhost User. Scaffolding existing databases in ASP.NET Core (Scaffold-DbContext). To support both targets, edit the csproj to put : netcoreapp2.2 netstandard2.0Īfter all these you'll be able to run your Scaffold-DbContext command line with proper arguments and connection string. Understanding Entity Framework scaffold-dbcontext Commands in. Net Standard, you must also enable netcoreapp in it, or Scaffold-DbContext will complain. Late edit, there's something else to know : You can't run Scaffold-DbContext against a class library targetting only. Which I was able to fix by setting my class library as Startup project in VS (don't ask why as it seems meaningless, but it worked). Ensure the specified name isĬorrect and is referenced by the project. Unable to find provider assembly with name To select the right assembly as target for your commands in the top-right corner of the PM console (I am frequently fooled by forgetting it.)Īnother problem I encountered : with the dbcontext located in a separate class library, I was encountering the following error : Add Data Connection in Server Explorer Add EntityFramework Plugins Scaffolding Operation Add Connection String to appsettings.json Add DbContext to Startup. To have other dependencies (for example Microsoft.EntityFrameworkCore,, .) referenced depending of your needs. In ASP.NET Core, things like dependency injection, services that are going to be used, generally configured in Startup.cs class. For me apparently it worked once I have also ran in Package Manager console : Install-Package
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |