Abdel Raoof Olakara
Abdel Raoof Olakara

Reputation: 19353

Avoid getting data from entity framework's cache

I have a weired problem. One of the pages in my application show's status of tasks in a table. I am using entity framework ( entity to object) to do all the data handling with DB. I noticed that even though the status is updated in DB, its not reflected on my webpage even after continuous refresh! If i stop the server and start the application again (currently running on VS2008 dev server) the updated data is displayed!

Am I seeing the cached data? how do I prevent this from happening?

Upvotes: 1

Views: 2078

Answers (1)

Craig Stuntz
Craig Stuntz

Reputation: 126587

Your ObjectContext lifetime should be a single request. If you have a static context which stays alive forever, you'll see stale data... forever. Here's an example of how to do it.

Upvotes: 4

Related Questions