zzzprojects / GraphDiff

GraphDiff is a library that allows the automatic update of a detached graph using Entity Framework code first.
https://entityframework-graphdiff.net/overview
MIT License
333 stars 101 forks source link

many to many relation between graph leaves #123

Closed yohny closed 6 years ago

yohny commented 9 years ago

Hello, I'm trying to use GraphDiff to update a graph structure that has m:n relation in the deepest (leaves) level. the structure is as follows:

Company (top level) Department (middle level) Computer (bottom level)

The thing is that between computers there can be links that I want GraphDiff to update too. A Link represents a one way connection between 2 computers. Link has a Source and a Target properties that point to those computers. Those 2 foreign keys are a composite primary key of a link. Each computer has a collection of Inbound links (where the given computer is a Target) and a collection of Outbound links (where the given computer is a Source).

The problem is that the GraphDiff messes up the links - sets source and target to the same computer even though it is explicitly set to different computers. Here is sample VS2013 project that demonstrates the issue. Is this a raphDiff bug, or am I just using it incorrectly? Thanks

vaclav-antosik commented 9 years ago

Hello Yohny, I was debugging your issue using the latest version of repository (9e5ddfaa0ebde569169e9e6554a020ff046ba3b8) and I have found this condition here. So your scenario is not supported yet. GraphDiff can't recognize entities with composite primary keys.

If you are using GraphDiff nuget package(v2.0.1) you will not get this exception because the package has been generated from older source code without the check.