Hi all,
I'm trying to create a convention for a many-to-many mapping using
BeforeMapManyToMany.
At the moment, with the following BeforeMapManyToOne convention in
place, my many-to-many's keep turning into two one-to-many's in the
generated schema. I.e., it turns each side of the many-to-many into a
many-to-one foreign key.
mapper.BeforeMapManyToOne += (modelInspector,
propertyPath, map) => {
map.Column(propertyPath.LocalMember.GetPropertyOrFieldType().Name +
"Fk");
map.Cascade(Cascade.Persist);
};
What I'd like is to have the BeforeMapManyToMany convention state that
the many-to-many should be held in a table called <Entity1>_<Entity2>
having two columns, each with a foreign key to the respective side of
the relationship. E.g., a many-to-many between Product and
ProductCategories would be in the table Product_ProductCategory.
I've tried playing around with BeforeMapManyToMany, but I can't seem
to get it to have any effect. E.g.,
mapper.BeforeMapManyToMany += (modelInspector,
propertyPath, map) => {
map.Column(propertyPath.LocalMember.GetPropertyOrFieldType().Name +
"Fk");
// Something I'm missing?
};
Am I able to use a BeforeMapManyToMany convention to map the many-to-
many table or do I need to include an override for every many-to-many?
Thanks!
Billy McCafferty
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.