1

I have upgraded my project from FW 3.5 to 4.0. I was trying to get the Foreign key columns to the model, and obviously, VS does not do that on the "update from Database" command. so went in added an integer column to the entity and mapped it to the Foreign key field. When I compile I get the classic EF error "error 3007: Problem in mapping fragments starting at lines Column(s) are being mapped in both fragments to different conceptual side properties" I was wondering If I need to do something special (even If I have to manually edit the xml in the edmx file) so that can access the Foreign key values, instead of loading the navigation object int he old way. I was under the impression the EF4 natively exposes the Foreign key properties along with Navigation properties. May be I am wrong or MS is just bluffing :). BTW I see those properties to the newly added entities. Recreating the model the model from the ground up is not an option as the application is already in production.

Any help is appreciated. Thanks

Ladislav Mrnka
  • 360,892
  • 59
  • 660
  • 670
Bhuvan
  • 1,523
  • 4
  • 23
  • 49

1 Answers1

2

The problem is that you want to upgrade the independent association to the foreign key association (I have described the difference between them here). Adding a new property is just one step of this upgrade process. You must also change the relation between entities to use referential constraints instead of an association mapping. Here you have very nice blog post about the topic.

Community
  • 1
  • 1
Ladislav Mrnka
  • 360,892
  • 59
  • 660
  • 670
  • Thank You.. due to the title of the article "Upgrading Independent Association to Foreign Key Association", it is almost impossible to find it in Google by usual queries :). Thank You Ladislav and Zeeshan (for the the Blog)... this is very useful blog post.. and actually worked.. – Bhuvan Mar 14 '11 at 15:48