Open joakimskoog opened 8 years ago
Did you ever find a good solution for this? I'm trying to do bulk inserts into a many-to-many, but haven't found a great way to do this using EF / EF.Utilities.
I might be off here because I rarely use many-to-many relationships, but what if you explicitly create a class that will store the many-to-many relationship for you? To my understanding, EF code-first will generate a table automatically to store the many-to-many relationship. I can see how it's tough for EFUtilities to make use of this generated table, as it does not actually exist in the code-first model. If you write a class that holds the many-to-many relationships, you're effectively replacing the many-to-many relationships with two one-to-many relationships. Might be worth looking into.
That’s indeed possible, however a pain to work with. For example a parent-child relationship: parent.Children
would become something like parent.children.Select(x => x.Child)
. The m2m relationship is part of the metadata, however I’m not sure how to retrieve and link it to the class’ property.
Op 10 jun. 2019 om 23:49 heeft Rudey notifications@github.com het volgende geschreven:
I might be off here because I rarely use many-to-many relationships, but what if you explicitly create a class that will store the many-to-many relationship for you? To my understanding, EF code-first will generate a table to store the many-to-many relationship, I can see how it's tough for EFUtilities to make use of this generated table. If you write a class that holds the many-to-many relationships, you're effectively replacing the many-to-many relationships with two one-to-many relationships. Might be worth looking into.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.
First of all; great library, it works perfectly for me in almost all scenarios. The only problem I have is that I can't use
UpdateAll
for updating navigation properties in many-to-many relationships as seen below:Character configuration:
The following code won't update the join table with the correct ID's. I guess that I can create a stored procedure for this instead but it would be nice to have support for this in
EntityFramework.Utilities
or maybe I'm thinking about this in the wrong way?characterToUpdate.Books.Add(book);
EFBatchOperation.For(context, context.Characters).UpdateAll(charactersToUpdate, x => x.ColumnsToUpdate(y => y.Books));