I have a model with many-to-many relation.
I also have object1 and object2 entities. Object1 has a ICollection<Object2> property. Object2 has a ICollection<Object1>.
The problem is that Object1 may have more than one Object2 with the same key (Id). I mean that it is possible situation that ICollection<Object2> may have {Id=1, Id=2, Id=1, Id=3... etc} objects.
Then I’m calling SaveChanges only {Id=1, Id=2, Id=3} are saved in Database. How can I save many same objects of Object1 instance in many-to-many relation?
Unfortunately, you will need to do this with two one-to-many collections and an association object in the middle, e.g.
Object1Object2Assoc. This object would also need aCountproperty to represent its order in the collection and/or an Id property to distinguish itself from other similar associations.