Entity Framework CodeFirst KeyNotFoundException in MemberDomainMap

前端 未结 3 1506
傲寒
傲寒 2021-01-06 16:55

Trying to run down an error in my EF datacontext implementation that is yielding a fairly cryptic error.

Test Name:  Nodes_can_be_saved
Test FullName:  MyP         


        
3条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-06 17:22

    Well, after much searching through my code and rebuilding from scratch I found that the problem was actually that I had a derived class of Node that had a Uri as a property, which obviously failed mapping since it doesn't have a default constructor (and possibly other reasons). I solved it for now by simply changing the property to a String which I validate as a Uri internally, though I would have preferred a more elegant solution. I tried mapping Uri and even a custom subclass (w/ default constructor) of Uri to a complextype, but that didn't help.

    Still, the question above is answered.

提交回复
热议问题