1

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 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.

  • The EF will infer all of this if you have a proper FK in your DB. Do you? – Craig Stuntz Jun 15 '11 at 20:37
  • lol, funny story... I'm using "views" designed by someone else (a company DBA). :( –  Jun 16 '11 at 15:33
  • 1
    OK, that's your problem, then. Since 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](http://stackoverflow.com/questions/1545131/entities-adding-a-navigation-property-between-a-view-and-table), since it can't be inferred from metadata. – Craig Stuntz Jun 16 '11 at 15:52
  • Craig if you post that as an answer I'll gladly accept it. –  Jun 29 '11 at 18:04

1 Answers1

1

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.

Community
  • 1
  • 1
Craig Stuntz
  • 125,891
  • 12
  • 252
  • 273