Closed sjh37 closed 1 year ago
Thanks for posting this, saved me some headache trying to figure out what was going on. As of June 11th, it looks like Microsoft Addressed it: "A fix for this issue has been internally implemented and is being prepared for release. We'll update you once it becomes available for download." (Phil Allen)
Microsoft have now resolved the issue in Visual Studio v17.6.4. More info here.
Upgrading to Visual Studio 17.6 breaks the generator for
FileManagerType.VisualStudio
(.NET 4.x framework projects)If you are experiencing this issue, please upvote this Microsoft ticket
.NET Core or SDK-style projects are not affected.
Quick fix
If you are generating the files into a single .cs file (
Settings.GenerateSeparateFiles = false
) or your project .csproj is the newer SDK style, you can setSettings.FileManagerType = FileManagerType.EfCore;
This bypasses theEF6.Utility.CS.ttinclude
file management.Permanent fix
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:to
Save the
EF6.Utility.CS.ttinclude
file.Details of the issue
The\Microsoft Visual Studio\2022\Community\Common7\IDE\PublicAssemblies) changes the visibility of the \Microsoft Visual Studio\2022\Community\Common7\IDE\Extensions\Microsoft\Entity Framework Tools\Templates\Includes).
Microsoft.VisualStudio.TextTemplating.dll
build supplied with Visual Studio 17.6.0 (inTextTransformation.GenerationEnvironment
property from “protected” to “public”. This breaks the DynamicTextTransformation class in both EF6.Utility.CS.ttinclude and EF6.Utility.VB.ttinclude (both inThe DynamicTextTransformation class attempts to access
TextTransformation.GenerationEnvironment
using reflection with the “Instance” and “NonPublic” binding flags. This fails now that TextTransformation.GenerationEnvironment is public, and DynamicTextTransformation throws a NullReferenceException error.