EF 4 - associations with keys that dont match
Posted
by Steve Ward
on Stack Overflow
See other posts from Stack Overflow
or by Steve Ward
Published on 2010-04-27T06:49:46Z
Indexed on
2010/04/27
6:53 UTC
Read the original article
Hit count: 422
entity-framework
|entity-framework-4
We're using POCOs and have 2 entities: Item and ItemContact. There are 1 or more contacts per item.
Item has as a primary key:
ItemID LanguageCode
ItemContact has:
ItemID ContactID
We cant add an association with a referrential constraint as they have differing keys. There isnt a strict primary / foreign key as languageCode isnt in ItemContact and ContactID isnt in Item.
How can we go about mapping this with an association for contacts for an item if there isnt a direct link but I still want to see the contacts for an item?
One of the entities originates in a database view so it is not possible to add foreign keys to the database
Thanks
Stephen Ward
© Stack Overflow or respective owner