Reputation: 447
When using entity framework, when reading from some tables/views, it seems I get old data back. By this I mean that an external process has changed the data.
When running my code, I see EF build and run (using profiler) an SQL query to retrieve the data, but then the old values end up in the object.
What is more confusing to me is that this does not happen for all tables/view, but for the tables/views it does effect, it is consistent.
If I restart IIS I get the correct result, so clearly the values are being held somewhere.
What is causing this selective cacheing of data and how do I influence it?
Upvotes: 0
Views: 117
Reputation: 2204
This is normal when you use same instance of ObjectContext
to long. Make it's lifetime as short as possible. Instance per request should be fine.
Upvotes: 1