Make changing many-to-many collections easier #27677
Labels
area-change-tracking
consider-for-current-release
customer-reported
punted-for-7.0
Originally planned for the EF Core 7.0 (EF7) release, but moved out due to resource constraints.
type-enhancement
Milestone
I have a ManyToMany relationship that I want to update. My steps to update are:
This works with a OneToMany relationship. Which surprised me, because I expected the familiar "entity with the same key value is already being tracked" exception.
I know how to solve my particular problem, but I'm curios if there is a way to make the "just clear and add the new state" method work on ManyToMany relationships?
Am I even supposed to use this method on OneToMany relationships or does it have any bad effects?
I saw that it fires a full UPDATE statement for every child and every field. Not optimal, but if I know about this behavior I can decide if the simpler code is worth it for me.
I would have expected this drawback to not even exist for the ManyToMany case, since its only updating/creating the joinEntity.
I created a fully reproducible sample.
Include provider and version information
EF Core version: 6.0.3
Database provider: Sqlite
The text was updated successfully, but these errors were encountered: