I\'m trying to generate classes from a database (EntityFramework\'s database first approach).
For convenience, I\'m more or less walking along with this tutorial: ht
Make sure your build works fine.
Run the scaffold command from the package console, your command should work:
Scaffold-DbContext 'Data Source=TEST-XY010;Initial Catalog=TESTDB;Trusted_Connection=True' Microsoft.EntityFrameworkCore.SqlServer -Context HOPWAContext -OutputDir TESTModel -Force
Thanks to the above, rebuilding the project solution solved this. Some crucial caveats for me personally were:
dotnet build was not enough (I had asssumed it was)!dotnet build command while inside a child project (myProject.data)I hope that helps someone else who was equally confused!
If entity-framework returns build failed, most probably you have some kind of error in any of your projects.
Even if the project you are running the command on, is clean and error-free, other projects in that solution can cause the build failed response.
Solution
Default project drop-down inside Package Manager ConsoleMake sure you have all packages and press ctrl + shift +b to build the solution. It works to me.
If you use multiple projects in the solution, check the default project in the package manager.
Manually building the project by pressing Ctrl+Shift+B helped me to see the errors that were causing the build to fail.