What are the drawbacks of initially turning off ProxyCreationEnabled for EF code CTP5?

c# entity-framework proxy-classes serialization wcf

Question

My WCF service can only retrieve classes from a code first model if the "Code First Model" property is set to "True"ProxyCreationEnable to false using the following code.

((IObjectContextAdapter)MyDb).ObjectContext.ContextOptions.ProxyCreationEnable = false;

What would be the drawbacks of doing this? At least getting these dynamic types serialized so they can be sent over the wire via WCF is a benefit.

1
81
8/6/2015 2:42:18 PM

Accepted Answer

Change tracking and lazy loading are accomplished through dynamic proxies. Although the relevant context is typically closed and disposed away when WCF attempts to serialize an object, serializing navigation properties will automatically cause lazy loading (on a closed context), leading to an error.

If you disable lazy loading, any navigation properties you wish to utilize will need eager loading (Include on ObjectQuery). WCF does not support tracking changes; this functionality is limited to entity modifications that are tied to an ObjectContext.

70
1/6/2011 12:06:59 PM

Popular Answer

If DbContext.Configuration.ProxyCreationEnabled in place tofalse DbContext won't load children for a certain parent object untilInclude the parent object receives a method call. SettingDbContext.Configuration.LazyLoadingEnabled to true or false has no effect on how it behaves.

If DbContext.Configuration.ProxyCreationEnabled in place totrue , automatically loaded child objects, andDbContext.Configuration.LazyLoadingEnabled Value will determine how soon child objects load.



Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow