Self referencing entity & insert order - using Entity Framework Code First

谁说我不能喝 提交于 2019-12-04 16:05:03
Gram

I have had the same error with foreign keys using EF. It may not be related however the answer that was provided helped me understand why I was getting the error.

Issue with EF and Foreign keys

In summary of Slauma's answer I was clearing the vertical navigation values before my EF insert. This caused an issue, all-though it is a different issue it may help.

Potential Solution

If you where to all your AssetSession object to your Asset object and then do one root add that should allow EF to insert both correctly.

Note: To do this you may need to generate your GUID in advance of inserting your objects.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!