简体   繁体   English

如何通过Entity Framework验证表之间的所有关系?

[英]how I can verify all the releations between tables by Entity Framework?

I am trying to build application that shows all the relations between tables 我正在尝试构建显示表之间所有关系的应用程序

one-to-one // 一对一 //

many-to-one // 多对一 //

manyto many 多对多

does there is an option to get the relation between two entities via EntityFramwrok for any exisiting database ? 是否可以通过EntityFramwrok获取任何现有数据库的两个实体之间的关系?

Thanks 谢谢

In Entity framework, you can create a .edmx file from an existing database. 在实体框架中,您可以从现有数据库中创建.edmx文件。 After creating edmx, you will get a model showing relationship between all the entities. 创建edmx之后,您将获得一个模型,显示所有实体之间的关系。

Follow the steps as given in this link- 请遵循此链接中给出的步骤-

Entity Framework Database First 实体框架数据库优先

If you need to retrieve to retrieve relationships from a generic database (of a third party application) creating an edmx on the fly, probably is not the best option. 如果您需要检索以从通用数据库(第三方应用程序的数据库)中检索关系,以动态创建edmx,则可能不是最佳选择。

The best way to retrieve relationships is to use system tables. 检索关系的最佳方法是使用系统表。
The only issue is that you won't be able to understand many to many relationships because in R-DBMS you have to use a junction table to map them (you can use an algorithm to immagine if a table is a junction table but you can't be sure). 唯一的问题是您将无法理解多对多关系,因为在R-DBMS中,您必须使用联结表来映射它们(您可以使用算法来想象表是否为联结表,但是您可以(不确定)。 By the way, you have the same issue using EF. 顺便说一句,使用EF存在相同的问题。 If you think that this could be a solution you can have a look here Know relationships between all the tables of database in SQL Server to see the query in SQL Server. 如果您认为这可能是一种解决方案,则可以在这里了解一下SQL Server中数据库的所有表之间的关系,以查看SQL Server中的查询。

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

相关问题 如何使用 linq 和实体框架访问表中特定列的所有值? - How can I access all values from a specific column in tables using linq and Entity Framework? 如何使用实体框架获取数据库表的数量? - How can I use entity framework to get a count of database tables? 如何使用实体框架处理可选表? - How can I deal with optional tables using Entity Framework? 如何让实体框架不为某些表创建类? - How can I make Entity Framework not create a class for some tables? 如何使用与Entity Framework一起使用表的存储过程 - How can I use a stored procedure that uses tables with Entity Framework 如何使用Entity Framework 6在运行时创建数据库和表? - How can I create a database and tables at runtime using Entity Framework 6? 实体框架代码优先:如何在两个表之间创建一对多和一对一的关系? - Entity Framework Code First: How can I create a One-to-Many AND a One-to-One relationship between two tables? 如何在 Entity Framework LINQ To Entities 中进行联合? - How can I do a Union all in Entity Framework LINQ To Entities? 如何通过实体框架获取表的所有关系列表? - How can I get all the relationships lists of a table by Entity Framework? 实体框架 - 如何在多个应用程序之间共享一些表 - Entity framework - How to share some tables between multiple applications
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM