简体   繁体   English

在实体框架C#中从父实体获取子实体

[英]Getting child entity from parent entity in entity framework c#

I have 1 to many relationship tables in SQL and I am using EF in MVC. 我在SQL中有1到许多关系表,并且在MVC中使用EF。 I would like to get all relational child from parent table. 我想从父表中获取所有关系子级。 relationship is setup on DB level. 关系是在数据库级别上设置的。 PK to FK etc. PK到FK等

I want to delete entity with child (and child of child). 我想删除有孩子(和孩子的孩子)的实体。

please advise. 请指教。

Thanks 谢谢

In the model configuration, you need to define child properties relations with WillCascadeOnDelete() 在模型配置中,您需要使用WillCascadeOnDelete()定义子属性关系

Plenty of examples are available on MSDN. MSDN上提供了大量示例。 For starters check here 对于初学者,请在这里检查

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

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