EF 6.1 ProxyCreationEnabled和LazyLoadingEnabled之间的区别 [英] EF 6.1 Difference between ProxyCreationEnabled and LazyLoadingEnabled

查看:357
本文介绍了EF 6.1 ProxyCreationEnabled和LazyLoadingEnabled之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在您的DbContext中,您可以配置以下两个参数:

In your DbContext you can configure the following two parameters:

context.Configuration.ProxyCreationEnabled = true;
context.Configuration.LazyLoadingEnabled = true;

我的理解是,为了启用延迟加载,您必须能够为实体创建代理。换句话说,两个参数都需要设置为true才能启用延迟加载。

My understanding is that to enable lazy loading you have to be able to create proxies for the entities. In other words both parameters need to be set to true to enable lazy loading.

1。为什么两个参数都存在,为什么可以同时配置这两个参数?

2。以下配置的效果如何?

// Can't create proxies but can lazy load
context.Configuration.ProxyCreationEnabled = false;
context.Configuration.LazyLoadingEnabled = true;

// Can create proxies but can't lazy load
context.Configuration.ProxyCreationEnabled = true;
context.Configuration.LazyLoadingEnabled = false;


推荐答案

AFAIK:


  • 代理创建 true 和延迟加载 true =>

    • 更改跟踪

    • 延迟加载

    • proxy creation true and lazy loading true =>
      • change tracking
      • lazy loading

      • 更改跟踪


      • ...


        参考(其他): msdn

        这篇关于EF 6.1 ProxyCreationEnabled和LazyLoadingEnabled之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆