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.
Visual Studio, ASP .NET Core WebAPI, Add Controller Wizard (for EF) has stopped working
I've created an ASP .NET Core WebAPI solution. I have successfully created 5 controllers using the Add Controller Wizard (API->API Controller with actions, using Entity Framework). Compiles and runs fine.
Now the wizard is not working. It fails silently but leaves text in the Output:
Initializing scaffolding model...
No properties found for
--model 'CB' Invalid
--model 'CB'
An error occurred.
The solution compiles without errors. I'm using the EF 8.27 versions of the needed packages.
If I drop a controller that successfully was added by the wizard before, I can't recreate the controller (so, I don't think this is the model at all). I cleaned, deleted obj and bin, rebooted. The usual stuff.
I can create and empty EF controller and I can get that to work but I really want the wizard to work correctly. I don't want to write all the methods by hand.
Developer technologies | Visual Studio | Other
1 answer
Sort by: Most helpful
-
AI answer
2026-05-17T20:47:04.13+00:00 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:
- Tutorial: Create a controller-based web API with ASP.NET Core
- Part 4, add a model to an ASP.NET Core MVC app
- Tutorial: Get started with EF Core in an ASP.NET MVC web app
- Add Models and Controllers
AI-generated content may be incorrect. Read our transparency notes for more information. - Verify required scaffolding packages are present
In the Web API project’s