Reputation: 4526
I am trying to use EF Core for .NET Core but I keep getting "build failed." when I run a properly configured Scaffold-DbContext command.
Does anybody know how to turn on logging so I can see more details about what is causing the failure?
Unfortunately, "Build failed." just isn't enough to go on!
Upvotes: 2
Views: 2950
Reputation: 57
Just hit this today. Apparently the "Scaffold-DbContext" command forces a solution build ... when it says "Build failed" it means the solution won't build, which has nothing to do with EF or its generated models. This is in the documentation but very easy to miss, some blurb about needing the connection string (which i pass in manually) and "configuration of the model", which isn't explained. Regardless, attempting to regenerate models on an unbuildable solution fails with "Build failed" without any hint that it's not building models like the command would suggest it's doing.
The -Verbose option does nothing for this, like helpfully say it's trying to build the solution, not the models. It does report the configured startup project, but nothing actually useful.
A workaround would be to use the equivalent dotnet command, which has a --no-build option, that causes it to pull info from the last known good build, or some such. I didn't use that, I fixed the solution so it would build and all was good.
Hope this helps...
Upvotes: 2
Reputation: 11
Depending where you run the command, the syntax is different. Check this link for examples: https://learn.microsoft.com/en-us/ef/core/managing-schemas/scaffolding?tabs=dotnet-core-cli
.Net core CLI > dotnet ef dbcontext scaffold
Visual studio package manager console > Scaffold-DbContext
Upvotes: 1
Reputation: 30405
Try manually building (Build > Build Solution) and looking at the errors (View > Error List).
Upvotes: 2
Reputation: 11661
If you googled the command: 'Scaffold-DbContext', you would have found the documentation here.
It tells you, you need the latest version of powershell.
and gives you the following tip:
On .NET Core and ASP.NET Core projects, add -Verbose to any Package Manager Console command to see the equivalent .NET Core CLI command that was invoked.
So run the command with -Verbose
:
Scaffold-DbContext [Your extra arguments] -Verbose
Upvotes: 0