NajiMakhoul
NajiMakhoul

Reputation: 1717

Scaffold-DbContext ignores build errors

How can I run Scaffold-DbContext while ignoring build errors ?

I removed all the modules and need to create it again. When I run the Scaffold-DbContext command it gives a lot of builds errors:

Scaffold-DbContext "Server=CONNICTION_STRING" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models -f

I have tried the -no-build parameter but it's not working (https://github.com/dotnet/efcore/issues/9484)

Scaffold-DbContext : A parameter cannot be found that matches parameter name 'no-build'. At line:1 char:193 + ... ntityFrameworkCore.SqlServer -OutputDir Models -no-build -f + ~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Scaffold-DbContext], ParameterBindingException + FullyQualifiedErrorId : NamedParameterNotFound,Scaffold-DbContext

Upvotes: 0

Views: 2510

Answers (2)

adam0101
adam0101

Reputation: 30995

  1. Ensure the entities are generated in their own project and add it as a project reference.
  2. Add a reference to Microsoft.EntityFramework.Core.Design in this project.
  3. If you have build errors in other projects in your solution, you can still regenerate by temporarily unloading those projects. (right-click on the project with errors and click "Unload project"
  4. After regenerating, reload your projects. (right click on the unloaded project and click "Reload project"

Upvotes: 0

Zhi Lv
Zhi Lv

Reputation: 21343

How can I run Scaffold-DbContext while ignoring build errors ?

You cannot run the Scaffold-DbContext command when there is a project build error. This is by design. You can submit feedback about this feature on the EF Core forum.

And from the Scaffold-DbContext, we can see there doesn't have the -no-build parameter.

Upvotes: 2

Related Questions