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.
There are a couple of options to get rid of circular dependencies. For a longer chain, A -> B -> C -> D -> A , if one of the references is removed (for instance, the D -> A reference), the cyclic reference pattern is broken, as well. For simpler patterns, such as A -> B -> A , refactoring may be necessary.
In software engineering, a circular dependency is a relation between two or more modules which either directly or indirectly depend on each other to function properly. Such modules are also known as mutually recursive.
Notice the navigation property check boxes, you can deselect them if you don't want them to be generated. To solve your circular reference problem, make sure only one or none are checked, not both.
and, yes, cyclic dependencies are bad: They cause programs to include unnecessary functionality because things are dragged in which aren't needed. They make it a lot harder to test software. They make it a lot harder to reason about software.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With