I have to an existing schema and I want to map it with nhibernate.
entities / table schema:
post {
pk_id
prod_id
prod_internid
title
}
tag {
pk_t_id
prod_id
prod_internid
name
}
A post can have multiple tags and there is a foreign key contraint from the tag to the post table with the two columns prod_id and prod_internid.
I've tried this:
PostMap {
// tags is a list
HasMany(x => x.tags).KeyColumns.Add("prod_id", "prod_internid");
}
TagMap {
References(x => x.post).Columns("prod_id", "prod_internid");//.ForeignKey();
}
I get this error:
NHibernate.FKUnmatchingColumnsException: Foreign key (FK98806C8630C05A78:tag [prod_id, prod_internid])) must have same number of columns as the referenced primary key (post [pk_id])
How can I map it the right way?