Fixing dotnet-aspnet-codegenerator error

Written by Mathew Grabau -

After reading the instructions just a bit closer, I finally solved the problems with ASP.NET Core Scaffolding. The Scaffolding feature initializes after first right-clicking on Controllers, then navigating to and clicking Add->Controller. Once the dialog was filled out (for example, with "CompanyController") it would fail with an an error

There was an error running the selected code generator: 'No executable found matching command "dotnet-aspnet-codegenerator"'

This was also affecting Razor Views. The solution is in the first step shown in ScaffoldingReadMe.txt (opens after the scaffolding is added):

  1. Add Scaffolding CLI tool to the project's .csproj file:
<ItemGroup>

    <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.1" />

</ItemGroup>