Visual Studio 2022 new Blazor server-side application .NET 9
I used EF Core Power Tools to import my SQL Server database as a DbContext and model classes.
I used the UI in VS2022 for Add/New Scaffolded Item, Common/Blazor/Razor Component, "Razor Components using Entity Framework (CRUD)" to create a set of CRUD pages for my first model class that was imported from the database. That worked fine. I got my Create, Delete, Details, Edit, and Index pages, which worked.
After futzing around with those pages for a day or two, I went to scaffold pages for my next model class.
I attempted multiple times and it would always run for a bit and then eventually display an error dialog that included the message "No code generators found with the name 'blazor'".
I searched the Web. I found similar reports. I tried all the suggestions.
From the command line, I uninstalled and reinstalled and updated dotnet-aspnet-codegenerator.
I ran the CLI command dotnet aspnet-codegenerator --help
. It returned "No code generators are available in this project.Add Microsoft.VisualStudio.Web.CodeGeneration.Design package to the project as a NuGet package reference".
I DID already have Microsoft.VisualStudio.Web.CodeGeneration.Design in my project. I removed it, saved, rebuilt, added it back, tried again. Same results.
My presumption is that the error message from trying to scaffold in the UI in VS2022 is a result of the same issue I get from the CLI. I.e. for some reason, dotnet can no longer find its code generators.
Why is this happening?
Visual Studio 2022 new Blazor server-side application .NET 9
I used EF Core Power Tools to import my SQL Server database as a DbContext and model classes.
I used the UI in VS2022 for Add/New Scaffolded Item, Common/Blazor/Razor Component, "Razor Components using Entity Framework (CRUD)" to create a set of CRUD pages for my first model class that was imported from the database. That worked fine. I got my Create, Delete, Details, Edit, and Index pages, which worked.
After futzing around with those pages for a day or two, I went to scaffold pages for my next model class.
I attempted multiple times and it would always run for a bit and then eventually display an error dialog that included the message "No code generators found with the name 'blazor'".
I searched the Web. I found similar reports. I tried all the suggestions.
From the command line, I uninstalled and reinstalled and updated dotnet-aspnet-codegenerator.
I ran the CLI command dotnet aspnet-codegenerator --help
. It returned "No code generators are available in this project.Add Microsoft.VisualStudio.Web.CodeGeneration.Design package to the project as a NuGet package reference".
I DID already have Microsoft.VisualStudio.Web.CodeGeneration.Design in my project. I removed it, saved, rebuilt, added it back, tried again. Same results.
My presumption is that the error message from trying to scaffold in the UI in VS2022 is a result of the same issue I get from the CLI. I.e. for some reason, dotnet can no longer find its code generators.
Why is this happening?
Share Improve this question asked Mar 28 at 15:42 StuartVStuartV 1352 silver badges10 bronze badges1 Answer
Reset to default 2I finally fixed it and it works now.
In my project file, there is an ItemGroup that contains this:
<PackageReference Include="Microsoft.AspNetCore.Components.QuickGrid.EntityFrameworkAdapter" Version="9.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="9.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="9.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<Publish>true</Publish>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="9.0.0" />
What is shown here is what works. What DID NOT work was that in this section the package reference for Microsoft.VisualStudio.Web.CodeGeneration.Design said version 9.0.0. But, all the other package references said version 9.0.3.
In the NuGet package manager it showed all my packages as being up to date - including Microsoft.VisualStudio.Web.CodeGeneration.Design with 9.0.0 being the latest available for it.
I manually edited the csproj file and changed all the references that said 9.0.3 to 9.0.0 and then it started working again.