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 102 forks source link

Deleting join row only in a many to many scenario #180

Open gjactat opened 4 years ago

gjactat commented 4 years ago

Hello, Maybe someone can help me with this one...

Description

I'm testing GraphDiff to circumvent the lack of support for detached graph updates in Entity Framework.

I have 3 tables : Users, Groups and UsersGroups which is a simple join table with two columns (UserId, GroupId). These two columns are the composite key. This way, users can belong to zero or more groups.

I have a Group1 entity with 3 users (UserA, UserB and UserC). If I serialize this object in JSON and try to UpdateGraph it back with only two users left (say UserA and UserB), then The UsersGroups join row <UserC, Group1> is deleted from the Database (which is fine).... But UserC is deleted as well (which is something I don't want here. I'd like to remove him from Group1 but keep him safe).

Is there any configuration trick that could handle this scenario ? Maybe something to change in the DB schema ?

Further technical details

Thanks for your attention !

JonathanMagnan commented 4 years ago

Hello @gjactat ,

Do you think you could provide a project sample with the problem you would like we solve?

It will help my developer investigate the issue more efficiently.

We now always ask for a project sample even if the issue is easy to reproduce. As a free product, we must find some way to save time to offer an overall better experience for everyone and release fixes faster.

You can send it to: info@zzzprojects.com if you need to keep the source private

Best Regards,

Jonathan


Performance Libraries context.BulkInsert(list, options => options.BatchSize = 1000); Entity Framework ExtensionsEntity Framework ClassicBulk OperationsDapper Plus

Runtime Evaluation Eval.Execute("x + y", new {x = 1, y = 2}); // return 3 C# Eval FunctionSQL Eval Function

JonathanMagnan commented 4 years ago

Hello @gjactat ,

Thank you for the report.

My developer looked at it and you are right. We currently do not support the many to many scenario in which you only want the relationship to be deleted.

The major issue is the entity is currently removed in the DbSet and not from the collection itself.

Unfortunately, I believe the development time for this request is a little bit too high to make it works property ;(

gjactat commented 4 years ago

Hello, Thank you for taking time to look into this issue. I'll stay tuned, just in case !