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

2
  • 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? Commented Dec 3, 2010 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? Commented Dec 3, 2010 at 14:38

2 Answers 2

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;
Sign up to request clarification or add additional context in comments.

Comments

4

In EF4 I had to use this instead:

_context.Configuration.LazyLoadingEnabled = false;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.