views:

34

answers:

1

Is it possible to set the name of the foreign key constraints added for a HasAndBelongsToMany relationship?

For BelongsTo there is a ForeignKey attribute, but there doesn not seem to be an equivilant for HABTM.

A: 

To the best of my knowledge, this is not implemented. But it would be great if you could implement it and contribute it to the project! This doesn't seem to be hard to implement. Source code is here, and the Castle team will be more than happy to help you with any issues or doubts, in the Castle dev mailing list.

Mauricio Scheffer
Looking at the code, it looks like HasAndBelongsToMany creates a collection (list, set, etc) in NHibernate. And I don't see a way to set the forein key constraint name on it either.
oillio
@oillio I'm pretty sure NHibernate accepts foreign-key in a many-to-many. See http://nhforge.org/doc/nh/en/index.html#schemattributes-summary
Mauricio Scheffer