8

We're having 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

Zack
  • 598
  • 3
  • 8
  • 23
  • Do you mean that you load entities and they don't somehow get reloaded from the database automatically? Or do you mean that your data context doesn't fetch data from the database every time you load an object? Can you show an example of what doesn't work for you? – mlibby Dec 03 '10 at 14:36
  • Hi, I mean that our data context doesn't fetch data from the database every time we load an object. We'd like it to, if it's possible? – Zack Dec 03 '10 at 14:38

2 Answers2

7

On the property sheet for your model, you can set the Lazy Loading Enabled property.

alt text

Through code, you can control lazy loading with the ObjectContextOptions.LazyLoadingEnabled property:

context.ContextOptions.LazyLoadingEnabled = false;
Jeff Ogata
  • 56,645
  • 19
  • 114
  • 127
4

In EF4 I had to use this instead:

_context.Configuration.LazyLoadingEnabled = false;
Lodlaiden
  • 361
  • 1
  • 10