循环依赖于实体框架 [英] circular dependency in entity framework
问题描述
是否有可能挽救已经得到了循环依赖的模式?
我非正规化我的数据库:
用户 -------- 用户帐号 用户名 LastOrder - FK去年订单 订购 ------- ORDERID OrderName 用户帐号 订购日期
是否有可能挽救某事像这样使用的EntityFramework?
我应该改变,使其工作,因为现在我有错误:
无法确定相关的操作有效的排序。 相关性可能存在由于外键约束,模型 要求,或者存储生成的值。
我有一个表,有一个关系到自己和我得到了同样的错误。原来,外键为可以为空。 在实体框架 同桌关系 我希望这样可以节省别人更多的时间比我浪费了。
Is it possible to save model which has got circular dependency ?
I denormalized my Database:
User -------- UserId UserName LastOrder - fk to last order Order ------- OrderId OrderName UserId OrderDate
Is it possible to save sth like this using entityFramework?
what should I change to make it work cause now I have got error:
Unable to determine a valid ordering for dependent operations. Dependencies may exist due to foreign key constraints, model requirements, or store-generated values.
I had a table that had a relationship to itself and i was getting the same error. Turns out the foreign key has to be nullable. Same table relationship in Entity Framework I hope this saves someone more time than I wasted.
这篇关于循环依赖于实体框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!