Reputation: 41
I get "Object reference not set to instance of an object" when I try to open my edmx file in EF 6. Is there any way to figure out what its missing?
Upvotes: 3
Views: 817
Reputation: 1
Go to
C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\Extensions\Microsoft\Entity Framework Tools\Templates\Includes
Start Notepad in administrator mode, and open the file (substituting Community for Professional or Enterprise depending on your version):
C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\Extensions\Microsoft\Entity Framework Tools\Templates\Includes\EF6.Utility.CS.ttinclude
Update the following code in DynamicTextTransformation (approx line 1920) and change:
_generationEnvironment = type.GetProperty("GenerationEnvironment", BindingFlags.Instance | BindingFlags.NonPublic);
to
_generationEnvironment = type.GetProperty("GenerationEnvironment", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
Basically, you need to add the BindingFlags.Public
to the options inside the GenerationEnvironment
.
This is a documented bug from VS2022. It looks like it will be fixed in new releases. (https://developercommunity.visualstudio.com/t/Cannot-import-anymore-tables-into-edmx/10368835)
Upvotes: 0