If technically possible or not, expressing such a relationship with "additional properties in the in the middle table" as many-to-many relationship is just wrong because it hides that the "middle table" has a business meaning and therefore must be an entity on its own.
A somewhat classical example for such a model are RawMaterial
and Product
: A RawMaterial
can be used in multiple Product
s and a Product
can be made of multiple RawMaterial
s. The entity in between - maybe called RecipePart
- contains a Quantity
how many pieces of a given RawMaterial
are used in a given Product
.
If you have for example the product ChocolateBar
and work with its relation to raw materials you will deal with a recipe that says a ChocolateBar
has 60 units of Chocolate
and 40 units of Milk
, i.e. ChocolateBar
has a collection of RecipePart
s and every RecipePart
describes the quantity and refers to the related RawMaterial
. A ChocolateBar
does not have a direct collection of RawMaterial
s in this business model.
For a particular query (maybe some statistics) you might be only interested in its raw materials - a chocolate bar is made if chocolate and milk, no matter how many units - but that is a special query in your business model and kind of an aggregation that ignores some pieces of the full detailed model information. This is what your helper property this.Select(p=>p.AB.B);
does: It does not express the full relationship but is a specialized query that says: Give me only the RawMaterial
s for this Product
, I don't want to know each quantity.
Characteristically you have left the property setter set { //... }
a stub. When adding or changing entities it becomes obvious that the relationship cannot be many-to-many. It is not possible to assign only a list of RawMaterial
s to a Product
. You must add the information how many units of each RawMaterial
to get a valid Product
model which means that Product
must be related to the "middle entity" RecipePart
.