具有指向非 PK 列的外键的表的实体图不会在图中显示关系
我有两张桌子,父母和孩子。
如果我在子项上创建一个指向父项主键的外键,然后创建实体图,则关系会正确显示。
如果我将外键指向不同的列,则不会显示关系。
我尝试向列添加索引,但没有效果。
数据库是 sqlite,但我不确定这是否有效果,因为它全部隐藏在 ADO.net 后面。
如何让这种关系正常运作?
这是在实体框架 (.edmx) 图表中使用 Visual Studio 2010,让它从数据库自动生成图表。
I have two tables parent and child.
If I make a foreign key on child that points to the primary key of parent, and then make an entity diagram, the relationship is shown correctly.
If I make the foreign key point to a different column, the relationship is not shown.
I have tried adding indexes to the column, but it does not have an effect.
The database is sqlite, but I am not sure if that has an effect since its all hidden behind ADO.net.
How do I get the relationship to work correctly?
This is using Visual Studio 2010 in the Entity Framework (.edmx) diagram, having it automatically generate the diagram from the database.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
外键必须引用父表中的候选键。因此,您在图中指向的列必须是候选键。这不一定是“主”键,但它必须是一组通过存在唯一性约束(通常是 UNIQUE 或 PRIMARY KEY 约束)来保证唯一的列。
A foreign key has to reference a candidate key in the parent table. The column(s) you are pointing to in the diagram must therefore be a candidate key. That doesn't have to be the "primary" key but it must be a set of columns that is guaranteed unique by the presence of a uniqueness constraint (usually a UNIQUE or PRIMARY KEY constraint).