Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Edmx missing foreign keys

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

like image 852
mashta gidi Avatar asked Mar 12 '26 21:03

mashta gidi


1 Answers

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.

like image 182
Rob Hardy Avatar answered Mar 15 '26 11:03

Rob Hardy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!