Tracking changes and creating proxies are two different scenarios. If you need to disable change tracking, you must do this as shown below.
public class YourContext : DbContext { public YourContext() { this.Configuration.AutoDetectChangesEnabled = false; } }
Then you cannot do it ChangeTracker.Entries<IAuditable>().Where(x => x.State == EntityState.Modified).ToList() .
If you need to disable proxy creation, you need to do this in the constructor of your context, as shown below.
public class YourContext : DbContext { public YourContext() { this.Configuration.ProxyCreationEnabled = false; } public DbSet<Blog> Blogs { get; set; } public DbSet<Post> Posts { get; set; } }
The proxy engine is used to support lazy loading relationships. EF will not create proxies for types where there is nothing for the proxy. In other words, if you do not have virtual properties in your POCO classes, then there is no effect that you have disabled or not.
If you are serializing your entities, then consider disabling proxies and lazy loading, since proxy deserialization can be complicated.
You can learn more about this here: Entity Framework Working with a proxy
Sampath
source share