Cannot generate controller from cli
See original GitHub issueWhen running dotnet aspnet-codegenerator controller -name AuthorController -async -api -m Author -dc MyDbContext -outDir Controller
I get the following error
Building project ...
Finding the generator 'controller'...
No code generators found with the name 'controller'
at Microsoft.VisualStudio.Web.CodeGeneration.CodeGeneratorsLocator.GetCodeGenerator(String codeGeneratorName)
at Microsoft.VisualStudio.Web.CodeGeneration.CodeGenCommand.Execute(String[] args)
RunTime 00:00:04.23
Steps to reproduce:
run dotnet aspnet-codegenerator controller -name AuthorController -async -api -m Author -dc MyDbContext -outDir Controller
Here is my csproj
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<GenerateDocumentationFile>false</GenerateDocumentationFile>
<UserSecretsId>xxx</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.10.9" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.3" />
</ItemGroup>
</Project>
Here is my dotnet-tools.json
{
"version": 1,
"isRoot": true,
"tools": {
"dotnet-ef": {
"version": "3.1.4",
"commands": [
"dotnet-ef"
]
},
"dotnet-aspnet-codegenerator": {
"version": "3.1.3",
"commands": [
"dotnet-aspnet-codegenerator"
]
}
}
}
Expected behavior:
Controller to be created
Actual behavior:
Failure
Building project ...
Finding the generator 'controller'...
No code generators found with the name 'controller'
at Microsoft.VisualStudio.Web.CodeGeneration.CodeGeneratorsLocator.GetCodeGenerator(String codeGeneratorName)
at Microsoft.VisualStudio.Web.CodeGeneration.CodeGenCommand.Execute(String[] args)
RunTime 00:00:04.23
Additional information about the project being scaffolded, such as:
Target framework(s):
netcoreapp3.1
Package version of Microsoft.AspNetCore.App or Microsoft.AspNetCore.All (if applicable):
Not manually selected
Package version of Microsoft.VisualStudio.Web.CodeGeneration.Design - this may be added to your project by scaffolding:
3.1.3
Issue Analytics
- State:
- Created 3 years ago
- Comments:18 (5 by maintainers)
Top Results From Across the Web
c# - Not able to generate controller and views from Entity ...
NET Core 3.1 I am looking for a way to generate controllers and CRUD views from the command line in Windows from my...
Read more >dotnet aspnet-codegenerator command
Generate controller with read/write actions without a model. Use the -h switch for help on the aspnet-codegenerator controller command: .NET CLI
Read more >Part 4, add a model to an ASP.NET Core MVC app
MvcMovieContext is generated. Select Add. In the Database provider drop down, select SQL Server. Views and Controller name: Keep the default.
Read more >The Rails Command Line
The Rails Command LineAfter reading this guide, you will know: How to create a Rails application. How to generate models, controllers, database migrations, ......
Read more >Implementing the IBM SAN Volume Controller with IBM Spectrum ...
You cannot create a child pool for a Data Reduction Pool (DRP) ... When the user logs on to the management GUI or...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I fixed it updating the codegenator package:
dotnet tool uninstall --global dotnet-aspnet-codegenerator
dotnet tool install --global dotnet-aspnet-codegenerator --version 3.1.4
dotnet restore
dotnet new globaljson --sdk-version 3.1.300
dotnet remove package Microsoft.VisualStudio.Web.CodeGeneration.Design
dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design -v 3.1.0
dotnet restore
dotnet build
You can see your SDKs and runtimes installed with.
dotnet info
you can see your packages with
dotnet list package
As for why this happened. No idea, Just downgrading my SDK, .NET core env and the package version worked for me.