Edmx missing foreign keys

1.5k Views Asked by At

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

1

There are 1 best solutions below

2
On

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.