ADO.NET Database first error after update (VS2022)

Joel Almeida 20 Reputation points
2023-05-22T20:29:49.6+00:00

Hello,

I updated VS2022 to V17.6.1 and I think that after this update (or previous one I'm not really sure) I get the error : "Running transformation: System.NullReferenceException: Object reference not set to an instance of an object.".
What happens is that the diagram is generated correctly with the changes I made but the Models .cs aren't created and I get the error. When I double click it it shows me the DbContext.tt file. I tried to compare it with one from a backup and they look like the same. I'm lost and can't get when I get this NullReferenceException. I never had this error before, even when updating models.

Greetings,
Joel

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,981 questions
Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
5,263 questions
{count} votes

Accepted answer
  1. Tianyu Sun-MSFT 31,611 Reputation points Microsoft Vendor
    2023-05-23T08:06:03.0533333+00:00

    Hello @Joel Almeida,

    Welcome to Microsoft Q&A forum.

    Probably, this issue is caused by updating VS 2022 to the latest version. Please kindly check these two threads: Create or recreate a Model does not work any more for winform .net framework solutions, Cannot import anymore tables into edmx. “Running transformation: System.NullReferenceException: Object reference not set to an instance of an object.”.

    If you get the same issue, please try the workarounds which are shared in above links and if possible, try to downgrade to a previous version of VS 2022 temporarily, for example, version 17.5.4/17.5.5.

    If the issue you get is different from the issues mentioned in above threads, please try following methods:

    1. Rename/remove ComponentModelCache folders in C:\Users\username\AppData\Local\Microsoft\VisualStudio\17.0_XXXXXXXX.
    2. Reset VS settings by running devenv /ResetSettings in Developer Command Prompt for Visual Studio 2022.
    3. Remove the hidden .vs folder in your solution folder and rebuild your project.

    Best Regards,

    Tianyu


    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.

    1 person found this answer helpful.
    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Dirk Pilipow 0 Reputation points
    2023-05-27T16:57:32.0866667+00:00

    Same problem here, but can't downgrade to 17.5.5 or 17.5.4 because rollback is only available for 17.6 and i can't find a bootstrapper for 17.5 Community Edition.

    https://stackoverflow.com/questions/76332260/visual-studio-17-6-1-update-ef6-no-longer-generating-classes might bei a solution for the problem. Worked for me with VS2022 17.6.2

    0 comments No comments

  2. Enrique Incio Chapilliquen 0 Reputation points
    2023-06-08T20:05:31.56+00:00

    I consider it disrespectful, since I am sure that most of them develop projects with emdx models and this is a waste of time for those of us who have to make a change in production and this is not the correct final version.

    0 comments No comments

Your answer

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