简体   繁体   English

Edmx缺少外键

[英]Edmx missing foreign keys

I am mapping my database using Entity Framework, using the database-first approach. 我使用数据优先方法使用Entity Framework映射我的数据库。

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. 问题是应该映射我的确切数据库的edmx文件缺少表之间的一些FK关系,这导致我更改我的查询,因为我不能直接接近相关表。

Of course changing it directly in the classes code, it's erased every time I change something in the database (the edmx is recreated). 当然,直接在类代码中更改它,每次我在数据库中更改某些内容时都会删除它(重新创建edmx )。

I need help please!!! 我需要帮助!

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. 从数据库创建模型时,会出现一个标记为“在模型中包含Foriegn Key列”的复选框 - 确保选中此项。

See this article for more info. 有关详细信息,请参阅此文章

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM