3
Running transformation: System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.VisualStudio.TextTemplating93D6F136794E0F2DED98BBB434C0AB6B1BABD9986CF045D207B1349AA5C562DE7F6768CC72494F822CD0E8B6D07104A542507F67E73B56FFE45CC4AB1D75F16F.GeneratedTextTransformation.DynamicTextTransformation.get_GenerationEnvironment()
   at Microsoft.VisualStudio.TextTemplating93D6F136794E0F2DED98BBB434C0AB6B1BABD9986CF045D207B1349AA5C562DE7F6768CC72494F822CD0E8B6D07104A542507F67E73B56FFE45CC4AB1D75F16F.GeneratedTextTransformation.EntityFrameworkTemplateFileManager..ctor(Object textTransformation)
   at Microsoft.VisualStudio.TextTemplating93D6F136794E0F2DED98BBB434C0AB6B1BABD9986CF045D207B1349AA5C562DE7F6768CC72494F822CD0E8B6D07104A542507F67E73B56FFE45CC4AB1D75F16F.GeneratedTextTransformation.EntityFrameworkTemplateFileManager.VsEntityFrameworkTemplateFileManager..ctor(Object textTemplating)
   at Microsoft.VisualStudio.TextTemplating93D6F136794E0F2DED98BBB434C0AB6B1BABD9986CF045D207B1349AA5C562DE7F6768CC72494F822CD0E8B6D07104A542507F67E73B56FFE45CC4AB1D75F16F.GeneratedTextTransformation.EntityFrameworkTemplateFileManager.Create(Object textTransformation)
   at Microsoft.VisualStudio.TextTemplating93D6F136794E0F2DED98BBB434C0AB6B1BABD9986CF045D207B1349AA5C562DE7F6768CC72494F822CD0E8B6D07104A542507F67E73B56FFE45CC4AB1D75F16F.GeneratedTextTransformation.TransformText() LIBRARY C:\Users\JD\Documents\Visual Studio 2022\Projects\ProjectName\LIBRARY\DBModel.tt    1

What is the solution to this error?

carloswm85
  • 1,396
  • 13
  • 23
  • 1
    Having the same issue on last VS2022 17.6.2 – GeorgeMR May 26 '23 at 17:25
  • in C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\IDE\Extensions\Microsoft\Entity Framework Tools\Templates\Includes\EF6. Utility.CS.ttinclude `private DynamicTextTransformation(object instance) { _instance = instance; Type type = _instance.GetType(); _write = type.GetMethod("Write", new Type[] { typeof(string) }); _writeLine = type.GetMethod("WriteLine", new Type[] { typeof(string) }); _generationEnvironment = type.GetProperty("GenerationEnvironment"); _host = type.GetProperty("Host"); _errors = type.GetProperty("Errors"); }` – Jahanzaib Khan May 29 '23 at 10:10
  • This issue is utterly odd, and recent. It should be reopened. Redirecting to and old question with a myriad of answers is of little use. – carloswm85 May 31 '23 at 17:18
  • This is the solution that worked for me: https://gist.github.com/carloswm85/461df6ad36c96e69a9dab0d88f599d39 – carloswm85 May 31 '23 at 17:50
  • 1
    Ongoing problem. See: https://developercommunity.visualstudio.com/t/Cannot-import-anymore-tables-into-edmx/10368835 and https://developercommunity.visualstudio.com/t/Object-reference-not-set-to-an-instance/10368943 – carloswm85 Jun 01 '23 at 12:22
  • The workaround described in this link worked for me: https://developercommunity.visualstudio.com/t/Entity-Framework-Running-Transformation/10371307 – napsebefya Jun 02 '23 at 11:45

0 Answers0