Search code examples
c#asp.net-core-webapi.net-5ef-database-first

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


Solution

  • 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.