Is there currently a way to use the equivalent of the index-many-to-many
NHibernate tag in Fluent NHibernate?
The mapping I am trying to achieve was generated almost perfectly using AsMap
on a HasManyToMany
, apart from this one element specifying the index in the map:
Generated was:
<index type=...
Should have been:
<index-many-to-many class=...
EDIT: Currently the workaround I am using is to generate the partially incorrect mapping, manually editing the mapping file, commenting out the mapping code and then manually adding the corrected mapping file in place of Fluent NHibernate generating it from the commented out mapping code. Not ideal since any time the mapping changes I need to go through this process again, but once my mappings do not change this will not be so much of an issue.
I solved this by using
AsTernaryAssociation
in addition toAsMap
.In summary, to map an
IDictionary<KeyEntity,ValueEntity>
I have the mapping:Note that including type parameters causes this to not work for some reason (i.e. the below will throw a
FluentNHibernate.Cfg.FluentConfigurationException
)I would be interested to know why the typed version does not work if anyone knows?