2

I need to map a legacy db that has composite foreign keys referring to non-primary unique keys.

First, I was trying to map it in EntityFramework. Unfortunately, I have found that EntityFramework (or at least 5.0) does not support that.

Now, I am trying to achieve that in NHibernate (with fluent mapping). However, I am unable to find any examples in the docs. Neither I have found that among the unsupported features.

Does NHibernate support that? Are there some samples or docs?

Community
  • 1
  • 1
TN.
  • 18,874
  • 30
  • 99
  • 157

1 Answers1

0

Use the CompositeId method to create composite keys.

CompositeId().KeyProperty(x => x.Property1).KeyProperty(x => x.Property2);
stuartd
  • 70,509
  • 14
  • 132
  • 163
  • How to map then the foreign keys to particular composite ids? (The legacy tables has multiple composite unique keys in addition to the primary key.) – TN. Jul 03 '14 at 07:57
  • Can you post a simple example of what you need to do? – stuartd Jul 03 '14 at 11:01