NHibernate (free) and many, many mappings with additional metadata
I am trying to decide how to manage the next relationship
There are many products
in the store The product is in many stores The store knows how much of each product it has
In the database, I have 3 tables, Stores and Store Store products that have StoreId, ProductId and quantity.
How do I map this in nHibernate or fluently nHibernate?
source to share
[This answer is ORM generic and not FNH specific]
In the (very good) book NHibernate in Action (see section 6.3.2), the authors argue that it's almost never worth using multivalued matching, because you almost always find (possibly later) that you want to attach additional metadata to "link" between these two objects, and therefore you can also model this right to your own right (as you say, did in your question).
As you already figured out, you need to create a StoreProducts object and many-one and one-many to complete the association.
... only if you want to confirm that this is the "recommended" approach :-)
source to share