skip to Main Content

Using ASP.NET Core 6.0 MVC, I’m attempting to create a web project with an n-tier architecture. I encounter the following issue when attempting to add a view from the Controller. After a few hours of investigation, I was unable to come up with a solution; therefore, I would appreciate your assistance.

Error message:

There was an error running the selected code generator: ‘Scaffolding failed. Could not load information for project
C:UsersPCsourcereposBlogProjectBusinessLayerBusinessLayer.csproj’

2

Answers


  1. Chosen as BEST ANSWER

    This is how i solved the bug temporarily, Within the View folder, I made a category folder (my controller's name). Index.cshtml was manually inserted to the category folder. I believe there is a general issue with nuget packages.


  2. @salihakdogan

    enter image description here

    This Issue relates the Microsoft.VisualStudio.Web.CodeGeneration.Design package. It often caused by using 6.0.9 version, 6.0.8 version and 6.0.0 version.

    It is a know Issue, You can follow this github issue to wait for the response from Microsoft.

    Or you can try to the following methods:

    Method 1:

    1. Remove the Database class library reference from the MVC project

    2. According to the models in the Database class library, create models
      (use the same name) in the MVC projects.

    3. In MVC projects, you can use Scaffold to add the generate pages with
      the new created models.

    4. Remove the models from the MVC project and re-add the Database class
      library project reference. [Note] You need to change the model
      reference in the generated page.

    Method 2:

    You can also create a new project which contains the MVC and Database models(put them in the same project), then generate the page using Scaffolded, after that you can copy the generated page to the original/main project.

    Method 3

    Try to downgrade the Asp.net 6 application to Asp.net 5(remember to downgrade the relates package, especially the Microsoft.VisualStudio.Web.CodeGeneration.Design package), then use Scaffold to generate the related views, after that migration the application from Asp.net 5 to Asp.net 6.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search