开发者

Create one-way association/mapping in Entity Data Model?

开发者 https://www.devze.com 2023-03-13 01:53 出处:网络
Okay, as usual, I\'m brand new to this... been researching and trial/erroring (yes that\'s a verb) for a couple hours with no luck.I have two tables.Application and ApplicationType.ApplicationType lis

Okay, as usual, I'm brand new to this... been researching and trial/erroring (yes that's a verb) for a couple hours with no luck. I have two tables. Application and ApplicationType. ApplicationType lists all the possible types. Let's use colors for simplicity. Red, Green, Blue, etc. So I have a column called *Type_ID* that would contain 1 for red, 2 for green, etc. Back to the Application table/entity, I have a column called *Type_ID* that corresponds. This is what I want to map. However, whenever I try, I continually get the error:

"Must specify mapping开发者_JAVA百科 for all key properties (Application_ID) of End Application in Relationship ApplicationTypeApplication"

*Application_ID* is the Entity Key for Application, obviously, but there is NO corresponding column in ApplicationType. Whenever I go to the table mapping details it always shows EVERY key. So, this is probably simply a major misunderstanding on my part, but any help would be much appreciated. I normally just use SQL queries but my coworker talked me into trying LINQ so her I am.


Since you are using a view and views don't have a proper PK, the EF defaults to treating all columns in the view as parts of a composite PK. You need to edit the mapping to correct the Key definition for the view, since it can't be inferred from metadata.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号