1

I found this article on using Sql Cache Dependency with Linq2SQL. http://www.dotnetcurry.com/ShowArticle.aspx?ID=263

is it possible to do this same thing in Entity Framework with DbContext?

I have a multi-database app so each DbContext Instance Connection is different depending on the user. But I feel like utilizing this technology would be the best way to invalidate the cache.

any help is appreciated.

Chase

1
  • Out of curiosity why do you want to refresh context if data change? Do you understand consequences? Commented Mar 21, 2011 at 19:08

2 Answers 2

1

Take a look at this, will give you a starting point: http://blogs.msdn.com/b/jkowalski/archive/2009/06/11/tracing-and-caching-in-entity-framework-available-on-msdn-code-gallery.aspx, I tried it and it works fine but I have chosen to use a more custom and light weight approach.

Basically I retrieve the TraceString which is nothing but the raw SQL from my IQueriable<T> and create a standard SqlCacheDependency cache entry.

Sign up to request clarification or add additional context in comments.

Comments

1

Your DbContext should live only for single unit of work. In your case for single request processing so there is no reason to involve any database dependency in EF.

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.