MVC 实体模型不显示我的表
我有一个包含多个表和一些基本关系的数据库。以下是我遇到的问题的示例:
我的数据库:
**Org**
ID
Name
etc
**Detail1**
ID
D1name
**Org_Detail1**
Org_ID
Detail1_ID
**Detail2**
ID
D2Name
**Org_Detail2**
Org_ID
Detial1_ID
BooleanField
我的问题是,Org_detail1 表没有显示在实体模型中,但 Org_Details2 表却显示在实体模型中。
我认为这可能是因为 Org_Detail1 表仅包含两个主键 ID 字段,而 Org_Details2 表包含 2 个主键 ID 字段以及一个布尔字段。
如果我向 Org_detail1 添加虚拟字段并更新它,它仍然不会显示,并且不允许我添加与 Org_Detail1 表相关的新实体。该表甚至不会显示在列表中,但它会列在表下。
有什么解决方案可以让该表出现在我的模型中吗?
I have a database with multiple tables, and some basic relationships. Here is an example of the problem I am having:
My Database:
**Org**
ID
Name
etc
**Detail1**
ID
D1name
**Org_Detail1**
Org_ID
Detail1_ID
**Detail2**
ID
D2Name
**Org_Detail2**
Org_ID
Detial1_ID
BooleanField
My problem is, the Org_detail1 table is not showing up in the entity model, but the Org_Details2 table does.
I thought it may have been because the Org_Detail1 table only contains two ID fields that are both primary keys, while the Org_Details2 table contains 2 primary key ID fields as well as a boolean field.
If I add a dummy field to Org_detail1 and update it, it still won't show up and wont allow me to add a new entity relating to the Org_Detail1 table. The table won't even show up in the list, but it is listed under the tables.
Is there any solution to get this table to appear in my model?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看来我可能只需要完全删除模型并重新创建它。添加虚拟字段是我找到的唯一解决方案。
Seems like I may just need to completely delete the model and recreate it. Adding dummy fields is the only solution I've found.
不确定这是 MVC 问题。
Detail1 集合是否出现在您的 Org 实体中,并且 Org 集合是否出现在您的 Detail1 实体中。这是实体框架对于没有其他有形数据的多对多相交表的正常行为。
如果没有,则可能未定义外键约束。
Not sure this is an MVC problem.
Does a Detail1 collection turn up in your Org entity and an Org collection show up in your Detail1 entity. This is the normal behaviour for Entity framework for a many to many intersecting table with no other tangible data.
If not then maybe the foreign key constraints are not defined.