Home  >  Q&A  >  body text

Error while trying to build a controller in ASP.NET Core 6 Web API - Visual Studio 2022

I have created a new ASP.NET Core 6 Web API project and am using an existing MYSQL database. I successfully set up the model and context from the database without any issues.

But when I try to build the controller, either using Add-> Controller-> API -> API Controller and Action, using Entity Framework (in Solution Explorer) or in Package Management Using the dotnet-aspnet-codegenerator controller command in the controller console I receive the following error:

I googled for solutions but can't seem to find any.

I'm new to C#/Visual Studio/.NET/EntityFramework (I'm used to using Node.js), so any help/advice is greatly appreciated.

P粉006977956P粉006977956237 days ago320

reply all(1)I'll reply

  • P粉111627787

    P粉1116277872024-02-26 11:44:06

    I have encountered the same problem before, because the low version of EF Core was caused by some cs syntax, helped me install the Microsoft.CodeAnalysis.CSharp.Workspaces package. Maybe your problem is the same, I hope this helps.

    reply
    0
  • Cancelreply