Why am I getting a NullReferenceException in System.Data.Entity.dll (Entity Framework)? Why am I getting a NullReferenceException in System.Data.Entity.dll (Entity Framework)? wpf wpf

Why am I getting a NullReferenceException in System.Data.Entity.dll (Entity Framework)?


If it's only for Nevada then it must be a data problem, do a thorough check in the db.

And to summarize, the core problem was:

  • It was db-first.
  • ... was returning a null value for one of the fields that was marked in EF as not null


I got the same problem when accidently loading a Module multiple times in a modular Architecture.

Additional, the Module(s) where using 2 copies of the same DbContext, trying to connect one Entity from one Context to another Entity of the other Context.

This masked the InvalidOperationException (cannot use an Entity in multiple Trackers), which occurs normally without the module stuff.

Took me 3 hours to solve, maybe it helps people with the same problem