I had the same problem, but to me, it happened when I made EF -Migrations. This error can cause both when you add a command for Migration (what was my case) or Scaffolding the DB. When you start the command, first, it builds the project and if there is a problem during the build process, it stops, does not continue, and returns just "Build failed" message. There is no Log Error message or additional information about the problem. The previous answers are correct. Firstly and mainly you have to check if there is no compile error and the project is building successfully.
- Right-click on the project level: Clean.
- Right-click on the project level: Build.
Or if you have multiple projects in one solution is better to do this at the Solution Level to check the entire application.
Let me say about my case where I have the same problem.
I have a large application with multiple projects in 1 solution which are not related
Without: Add > Project Reference...
to each other i.e. Microservices and what made it difficult for me to do a Migration and get -
Builder Failed
in one of the services i.e. "Order API". The problem was in another service, i.e. "Basket API" I made some changes earlier here, injecting an extra dependency in the constructor in that API Controller, and without noticing that it was missing mocking this dependency for this Controller where I did a unit test which causes Compile Error. As "Order API" was a startup project and my focus was here, didn't show me the compile error through the Re-Building only the Order API, but there was a problem when I was adding the migration in the Order API and the cause of the problem was in the Basket API > Integration Test.
- This is the example of my project solution:

I hope I explained well what happened in my case with "EF Migration - Builder Failed"; maybe it will be useful information.
- Also you can try to turn off visual studio, restart your PC and try again.
- I found some link about **EF - Scaffold ** Builder Failed:
Scaffold-Dbcontext build failed using EFCore commands