A family of Microsoft suites of integrated development tools for building applications for Windows, the web, mobile devices and many other platforms. Miscellaneous topics that do not fit into specific categories.
The scaffolding engine is failing to resolve the model type when running the “API Controller with actions, using Entity Framework” wizard. The key is to repair the scaffolding environment and EF tooling that the wizard depends on.
Use the following steps (in order) to restore the wizard:
- Verify required scaffolding packages are present
In the Web API project’s
.csproj, ensure the following packages exist with compatible versions (for ASP.NET Core + EF Core):-
Microsoft.VisualStudio.Web.CodeGeneration.Design -
Microsoft.EntityFrameworkCore.Tools -
Microsoft.EntityFrameworkCore.Design - The EF Core provider you use (for example
Microsoft.EntityFrameworkCore.SqlServer)
-
Microsoft.VisualStudio.Web.CodeGeneration.Design -
Microsoft.EntityFrameworkCore.Tools -
Microsoft.EntityFrameworkCore.SqlServer
-
- Rebuild the solution before running the wizard
The scaffolding engine uses reflection over the compiled assembly to find model and
DbContexttypes. If the project is not building, or if the build is stale, the wizard may report messages like:-
No properties found for --model 'CB' -
--model 'CB' Invalid
-
- Confirm the model and context types are valid
For the model type
CBthat the wizard is complaining about:- Ensure
CBis a public class in the project (or referenced project) and compiles. - Ensure it has public properties (the scaffolder expects properties to generate CRUD code).
- Ensure the
DbContextused by the wizard exposes aDbSet<CB>property.
DbContext, similar to the examples whereStudent/SchoolContext,Movie/MvcMovieContext, orTodoItem/TodoContextare used. - Ensure
- Repair the scaffolding tool chain (CLI side)
Even when using Visual Studio’s wizard, the underlying scaffolding engine is the same as the CLI
dotnet-aspnet-codegenerator. If it is in a bad state, reinstalling it and its supporting packages can fix silent failures. In the project folder (where the.csprojlives), run:
Then rebuild the project.dotnet tool uninstall --global dotnet-aspnet-codegenerator dotnet tool install --global dotnet-aspnet-codegenerator dotnet tool update --global dotnet-aspnet-codegenerator dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design dotnet add package Microsoft.EntityFrameworkCore.Design dotnet add package Microsoft.EntityFrameworkCore.SqlServer dotnet add package Microsoft.EntityFrameworkCore.Tools - Test scaffolding via CLI
To verify that the scaffolding engine itself works for the
CBmodel and its context (for exampleMyDbContext), run from the project folder:
If this succeeds, the underlying scaffolding engine is healthy; the Visual Studio wizard should also work again. If it fails with the same “No properties found” message, the issue is with the model or context definition (step 3).dotnet aspnet-codegenerator controller \ -name CBController \ -async -api \ -m CB \ -dc MyDbContext \ -outDir Controllers - Clear intermediate output and NuGet caches
Since deleting
bin/objdid not help, also clear NuGet caches and restore packages:- Close Visual Studio.
- Delete
binandobjfolders again. - Clear NuGet caches (for example via
nuget locals all -clearor Visual Studio’s NuGet options). - Reopen the solution and let NuGet restore packages.
- Rebuild and retry the wizard.
- As a fallback, scaffold a similar controller and adjust
If the wizard still fails specifically for
CBbut works for other models, scaffold a controller for a similar model that works, then copy/rename the generated controller and adjust the type names andDbSetusage manually. This avoids writing all methods from scratch while you continue to investigate whyCBis being rejected.
These steps align with how ASP.NET Core scaffolding is expected to work in Visual Studio and via the CLI, and they address the typical causes of “No properties found for --model” and silent wizard failures.
References: