Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Toggling ProxyCreation in EF7 under new configuration

So in EF6, one could disable proxy creation like so:

this.Configuration.ProxyCreationEnabled = false;

From what I could find, the configuration scheme under EF7 has changed, but I cannot find anything on how to do so. I went through https://docs.efproject.net/en/latest/miscellaneous/configuring-dbcontext.html and even analyzed the DbContextOptionsBuilder object, but cannot find anything on it.

Am I going about ti the wrong way or is there something im missing? Thanks in advance.

like image 696
Shadow3188 Avatar asked Mar 25 '16 15:03

Shadow3188


People also ask

What is proxy creation in Entity Framework?

When creating instances of POCO entity types, Entity Framework often creates instances of a dynamically generated derived type that acts as a proxy for the entity. This proxy overrides some virtual properties of the entity to insert hooks for performing actions automatically when the property is accessed.

How does EF track changes?

EF Core change tracking works best when the same DbContext instance is used to both query for entities and update them by calling SaveChanges. This is because EF Core automatically tracks the state of queried entities and then detects any changes made to these entities when SaveChanges is called.

What is ProxyCreationEnabled?

ProxyCreationEnabled is set to true , child objects will be loaded automatically, and DbContext. Configuration. LazyLoadingEnabled value will control when child objects are loaded.


1 Answers

EF7 EF Core 1.0 does not do proxy creation, so accordingly, there is no configuration option for this. See https://github.com/aspnet/EntityFramework/issues/997

like image 194
natemcmaster Avatar answered Oct 07 '22 01:10

natemcmaster