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?
Asked
Active
Viewed 507 times
2 Answers
0
Closing and opening the visual studio worked for me.

Amit K
- 9
- 2
-
Your reply is good for an comment, but not as an answer. It is rather advise then an solution – Tikky Sep 30 '20 at 18:22
-
1Re-opening visual studio did not work for me – Jigar Apr 26 '21 at 14:00
-
did not work for me either – kritikaTalwar Mar 01 '23 at 05:16
0
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)

maurow
- 1
- 1