can not generate controller - api controler with EF

Santhi Dhanuskodi 365 Reputation points
2023-08-21T14:26:16.2033333+00:00

Hi,

I am trying to generate controllers automatially using visual studio 'Add -controller - api controller with actions , using EF, but I get an error "Package restore failed". Tried all solutions available in internet, updated packages, reinstalled packages, cleared nuget cache etc... Cannt solve this issue.

User's image

User's image

User's image

Developer technologies | ASP.NET | ASP.NET Core
{count} votes

1 answer

Sort by: Most helpful
  1. Gyanendra Singh 0 Reputation points
    2025-05-27T14:08:19.8466667+00:00

    Hi @Santhi Dhanuskodi @Qing Guo - MSFT

    I realize this response is quite delayed, but I encountered the same issue today and found a solution:

    Make sure the NuGet package Microsoft.VisualStudio.Web.CodeGeneration.Design matches the .NET Core version used in your application. If it's missing, install the package and rebuild your project.

    After completing the above steps, try adding the controller again—this time, it should work like a charm!

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.