How to stop entity framework caching
We're havi开发者_运维知识库ng a problem testing Entity Framework 4.
We've deployed a WCF service that implements an EF data context. All works fine untill we modify the data using SQL server studio.
Is there a way to stop EF caching our results or is there any way to turn eager loading on?
Cheers,
James
On the property sheet for your model, you can set the Lazy Loading Enabled
property.
Through code, you can control lazy loading with the ObjectContextOptions.LazyLoadingEnabled
property:
context.ContextOptions.LazyLoadingEnabled = false;
In EF4 I had to use this instead:
_context.Configuration.LazyLoadingEnabled = false;
精彩评论