I have a problem with Microsoft.VisualStudio.Web.CodeGeneration.Design 6.0.9

My Nguyen 21 Reputation points
2022-09-22T15:07:58.71+00:00

When I add project reference and try adding Scaffolded, I get this error
243961-image.png

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,459 questions
ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,239 questions
.NET Runtime
.NET Runtime
.NET: Microsoft Technologies based on the .NET software framework.Runtime: An environment required to run apps that aren't compiled to machine language.
1,131 questions
{count} votes

Accepted answer
  1. Zhi Lv - MSFT 32,046 Reputation points Microsoft Vendor
    2022-09-23T08:20:11.573+00:00

    Hi @My Nguyen ,

    GenZBookWeb - When I add project reference GenZBook.DataAccess and add new Scaffolded item MVC Area, it throws an error. I think there's something wrong with CodeGeneration.Design 6.0.9. I tried to clean the solution/projects, rebuild and re-adding the Scaffold page but the error still occurs. Hope the helping, tks!!!

    Yes, you are right, the issue relates the CodeGeneration.Design package. I could reproduce the problem using 6.0.9 version, 6.0.8 version and 6.0.0 version. But it works well on asp.net 5 and CodeGeneration.Design 5.0.2.

    This is a known issue, you can also feedback this issue to the Scaffolding forum, hope they can fix it in the next version.

    As a workaround, you can try to the following steps:

    1. Remove the DataAccess reference from the GenZBookWeb project
    2. Create models (use the same name) in the GenZBookWeb projects
    3. In GenZBookWeb projects, you can use Scaffold to add the generate pages
    4. Remove the models from the GenZBookWeb project and re-add the DataAccess project reference. [Note] You need to change the model reference in the generated page.

    Besides, you can also create a new project, which contains the Web and DataAccess model in the same project, then generate the page using Scaffolded, after that you can copy the generated page to the GenZBookWeb project.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best regards,
    Dillion

    0 comments No comments

0 additional answers

Sort by: Most helpful