So I have a situation I'm trying to map with NHibernate. Say we have the following schema:
Question
- QuestionID
- QuestionText
- SiteID
Tag
- TagID
- TagName
- SiteID
QuestionTags
- QuestionID
- TagID
This would work fine for that:
<class name="Question" table="Questions">
<key column="QuestionID" />
<property name="QuestionText" not-null="true" />
<property name="SiteID" not-null="true" />
<set name="Tags" table="QuestionTags">
<key column="QuestionID" />
<many-to-many class="Tag" column="TagID" />
</set>
</class>
<class name="Tag" table="Tags">
<key column="TagID" />
<property name="TagName" not-null="true" />
<property name="SiteID" not-null="true" />
</class>
However, I want to add a SiteID column to QuestionTags, and add SiteID to each of its foreign keys...
(QuestionTags.QuestionID, QuestionTags.SiteID) -> (Questions.QuestionID, Questions.SiteID)
(QuestionTags.TagID, QuestionTags.SiteID) -> (Tags.TagID, Tags.SiteID)
...so that Questions and Tags with differing SiteIDs cannot be associated. How can I map that situation?