I’m running VS 2022, and have a Razor Pages site created. I tried to scaffold Razor CRUD pages and received the following error:
and this is what outputted:
Finding the generator ‘razorpage’…
Running the generator ‘razorpage’…
Minimal hosting scenario!
Exception of type ‘System.InvalidOperationException’ was thrown.
at Microsoft.VisualStudio.Web.CodeGeneration.ActionInvoker.b__6_0()
at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
at Microsoft.VisualStudio.Web.CodeGeneration.ActionInvoker.Execute(String[] args)
at Microsoft.VisualStudio.Web.CodeGeneration.CodeGenCommand.Execute(String[] args)
I had cleared the Nuget Package cache, updated all packages and still receive the error message.
The following are the nuget package versions I have in the csproj file:
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>Van_Authentication</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.8" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="8.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.8">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration" Version="8.0.5" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="8.0.5" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Utils" Version="8.0.5" />
<PackageReference Include="Nancy" Version="2.0.0" />
</ItemGroup>
Searching online, I cannot find any other solutions. I was able to scaffold pages earlier, so not sure what happened. I attempted to restore the project to an earlier GIT commit but it’s corrupted and won’t revert.
How do I fix the scaffolding error?
3
Install this package then try again.
Microsoft.VisualStudio.Web.CodeGeneration.Design
1