How do I map a composite primary key in Entity Framework 4 code first?
Posted
by jamesfm
on Stack Overflow
See other posts from Stack Overflow
or by jamesfm
Published on 2010-04-28T21:26:37Z
Indexed on
2010/05/26
12:31 UTC
Read the original article
Hit count: 1165
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?
© Stack Overflow or respective owner