I’m getting to grips with EF4 code first, and liking it so far. But I’m having trouble mapping an entity to a table with a composite primary key.
The configuration I’ve tried looks like this:
public SubscriptionUserConfiguration()
{
Property(u => u.SubscriptionID).IsIdentity();
Property(u => u.UserName).IsIdentity();
}
Which throws this exception:
Unable to infer a key for entity type ‘SubscriptionUser’.
What am I missing?
You could also use
Edit:
One limitation I have found is that the following do not work:
or
So how do you set up an entity where the join table has a primary key that is composed of foreign keys?