3

I am mapping my database using Entity Framework, using the database-first approach.

The problem is that the edmx file that should be mapping my exact database is missing some FK relations between the tables, which causes me to change my queries, because I can't approach the related tables directly.

Of course changing it directly in the classes code, it's erased every time I change something in the database (the edmx is recreated).

I need help please!!!

Gert Arnold
  • 105,341
  • 31
  • 202
  • 291
mashta gidi
  • 849
  • 1
  • 10
  • 30
  • 1
    If you have no alternative but to add the keys manually perhaps try adding them into a custom "partial" class with the same name as the Entity this should stop them getting blown away. – Rob Oct 11 '12 at 22:30

1 Answers1

4

When you create the model from the database, there is a checkbox marked "Include Foriegn Key columns In The Model" - Make sure this is checked.

See this article for more info.

Rob Hardy
  • 1,821
  • 15
  • 15