When to disable proxy generation and use AsNoTracking?

asp.net-web-api c# ef-code-first entity-framework graphdiff

Question

I utilize EF6, adhere to the Uow and generic repository principles, and map my models to dtos and vice versa in my WebApi project.

The following is what I now set when building thedbContext :

this.Configuration.LazyLoadingEnabled = false;
this.Configuration.ProxyCreationEnabled = false;

Also, I useAsNoTracking data retrieval from the database.

When dealing with small entities, I immediately attach the entities to the database context using the dbContext (ie. no relationships). For complex things, I use GraphDiff (ie. with relationships).

The SQL statement sent to the database includes all of the table's columns rather than just the ones that have actually changed when proxies and tracking are enabled, and even when they are disabled.

Before saving the modifications to the database, GraphDiff is reloading the entity. In this instance, all the columns are included in the SQL statement. Is this the right action to take?

I'm dealing with detached entities, so is it safe to disable proxies and tracking in my situation?

1
1
3/18/2016 5:15:34 AM

Accepted Answer

ZZZ_tmp
0
3/18/2016 9:15:10 AM


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