0

I have this existing project ASP.NET web application which is using .NET Framework 4.x and Entity Framework 6. For Entity Framework 6, it uses ADO.NET Entity Data Model > EF Designer from database.

The project could not compile due to one error. In the error list, it shows that the error is from Model.tt on the first line. <#@ template language="C#" debug="false" hostspecific="true"#>.

The error description is "Running transformation: System.NullReferenceException: Object reference not set to an instance of an object."

By the way, I also notice that initially there are some errors "The type or namespace name 'xxx' could not be found (are you missing a using directive or an assembly reference?)". I notice that Model.cs (the file under Model.tt) is empty. I have to manually copy the code from the repository to this class. After that, there is no more of this error "The type or namespace name 'xxx' could not be found (are you missing a using directive or an assembly reference?)".

Now I only stuck with one error "Running transformation: System.NullReferenceException: Object reference not set to an instance of an object." I am stuck with this as I am not so sure how to debug further.

This Model.tt class is auto generated using ADO.NET Entity Data Model > EF Designer from database.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
Steve
  • 2,963
  • 15
  • 61
  • 133
  • This `Model.tt` class is auto generated using `ADO.NET Entity Data Model` > `EF Designer from database` – Steve Aug 18 '23 at 08:02
  • Found the issue already. Delete the hidden .vs folder. Clean and rebuild. – Steve Aug 18 '23 at 08:40
  • In reviewing for reopen I noticed the OP had resolved his own issue here and it doesn't seem very useful any more. Voting to delete. – smathy Aug 24 '23 at 23:09
  • 1
    Also was reviewing for reopen and feel like the root cause was an EF code generation issue, not really a null reference issue, and others could benefit from the solution. I propose leaving it alone or adding an answer with the solution: Delete the .vs folder. – Darren Griffith Aug 25 '23 at 17:41

0 Answers0