Search code examples
c#.netwpf.net-4.8

ADO .Net EDM in visual studio 2022 doesn't generate model classes


I create a new wpf .net framework project. I connect ADO data models to it. enter image description here

Select database objects to include enter image description here

Database diagram is created fine enter image description here

But data model classes are not defined enter image description here

What could be the problem, I'm using Visual Studio 2022 version 17.6.1?

I tried reinstalling visual studio but that didn't help.


Solution

  • There are two solution:

    (1).Turn your visual studio version back to 17.5.x.

    (2)OpenC:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\Extensions\Microsoft\Entity Framework Tools\Templates\Includes\EF6.Utility.CS.ttinclude

    change line 1920:

    _generationEnvironment = type.GetProperty("GenerationEnvironment", BindingFlags.Instance | BindingFlags.NonPublic);
    

    to

    _generationEnvironment = type.GetProperty("GenerationEnvironment"); 
    

    this issue has been fixed in https://github.com/dotnet/ef6tools/commit/89cd126 by Adam Ratzman.