Open ajcvickers opened 1 year ago
I'm not sure what we decided any more, but assuming we support optional dependents for table sharing (do we?), would it still make sense to go through the motions of doing delete and insert like we'd do for non-table-sharing? Basically I'd expect Remove/Add to perform exactly the same regardless of whether there's a SaveChanges in between - except where doing that would raise an exception (i.e. non-optional table sharing).
But then we would have to also delete the other entities sharing the table, and re-create those, which would have different side effects.
But I'd assume that if we support optional table sharing, it should already be possible to delete the dependent without deleting the principal no? And if so, there's no reason to merge the delete/add for that case...
We can discuss.
See also the issue described here: #33653
https://github.com/dotnet/efcore/issues/1699 needs to be implemented before this, otherwise it would break the case where there's a relationship cycle in the database and all involved entities are replaced at the same time (already covered in tests).
Related: #33750 where we need to do the reverse
When two entity types share the same table, then deleting an instance and inserting a new instance into the same row is combined into an update for the row. This makes sense for table sharing, but we also started doing this for entities mapped to different tables. This causes problems when:
Therefore, we should stop doing this except where needed for table sharing.