Keith Barrows
Keith Barrows

Reputation: 25308

Entity Framework - Missing column(s)?

Model Image http://screencast.com/t/ODkwZDQx http://screencast.com/t/ODkwZDQx

I have a simple 3 table model built from my DB. Company has 0 or more ProductsSold. Company has 0 or 1 AutoNegotiationDetails. As you see from the diagram, this is what is modeled. However, in the ProductsSold Mapping Details you can see that the CompanyId Value/Property is missing. Nor can I add it. I have discovered that I can get to it programatically by going to ProductsSold.Company.CompanyId.

1) Is this correct? 2) Why does EF hide the FK field?

Upvotes: 4

Views: 2597

Answers (1)

Jason Rowe
Jason Rowe

Reputation: 6276

Originally Entity Framework did not support foreign keys or hid them. In a podcast with Julia Lerman, she mentions foreign keys were not included to avoid the scenario of multiple joins to get data. Also in the blog post it mentions "people say FKs pollute the conceptual model". Since this was such a divided subject the Entity Framework team has decide to add foreign key support in VS 2010 Beta.

In .Net 4 they have added FK Associations. You can read about them on the EF blog.

Upvotes: 2

Related Questions