Can I stop Entity Framework Core from populating my result with partial data?

白昼怎懂夜的黑 提交于 2019-12-02 13:13:41

I assume from your example that Alice's message with id 1 is linked to more that one user (herself).

I am not sure it is necessary to change this behavior. As you mentioned, we should use .ThenInclude(m => m.Users) if we need the navigation property to be fully initialized.

I would expect that unless I also added .ThenInclude(m => m.Users), it would give me a null or empty list, not a partial list.

The partial result will be a good thing when lazy loading will be implemented. If the navigation property you will want to access is already loaded, then you will save a round trip to the database.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!