entity framework 中的关系数据库预加载问题

Relational database eager loading issue in entity framework

我对关系数据库预加载的理解不清楚。 我的例子是 Children - Teacher 这是一个多重 relationship.My 问题是如果我们急于加载儿童实体,它将包含教师集合,这些教师将包含儿童列表,这将走多远以及如何停止一定水平。

My question is if we eager load children entity ,it will consist collection of teachers ,and those teachers will contain list of children ,How far this will go and how to stop from a certain level.

您不需要也不能停止此循环,因为这称为 EF/EF Core 代理创建。这是 EF/EF Core Eager Loading 的默认行为,没有办法阻止它。但是您可以停止 JSON 响应的自引用循环。

这里是关于这个的详细信息:Related data and serialization in EF Core