Entity Framework always includes data that is in context even if I don't ask for it

后端 未结 5 750
野趣味
野趣味 2021-02-07 02:18

I am using MVC.NET web api, EF with DB first, and I have lazy loading turned off on my context. EF is returning way too much data, even with LazyLoading turned off.

For

5条回答
  •  悲&欢浪女
    2021-02-07 02:52

    I don't want it to load anything besides what I tell it to include.

    It looks like you need to use Explicit Loading. Basically, you could load the specific entities like this:

    context.Include("Roles")
    

    To my best knowledge that should not include related entities. Lazy loading should indeed be disabled and you could load navigational properties explicitly with Load.

提交回复
热议问题