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

前端 未结 2 1859
说谎
说谎 2021-01-17 19:22

I have a List of State entity objects, and each State object has collections of other objects, such as Licenses

相关标签:
2条回答
  • 2021-01-17 20:04

    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

    0 讨论(0)
  • 2021-01-17 20:19

    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
    0 讨论(0)
提交回复
热议问题