Some great Entity Framework Guidance about Performance in client applications

I have spent a lot of time thinking about Entity Framework in web applications and in SOA and worrying about performance, serialization and concurrency.

But I haven’t spent a lot of time worrying about these things with respect to client apps (winforms and WPF).

In a great thread started by Nick in the forums where he was asking about keeping huge lists around in an application without having to hit the db over and over, both Danny Simmons and I assumed he was talking about web apps and started down the whole serialization/caching path.

But it turned out that Nick was worried about a WPF app which changes everything when you are thinking about performance.

In the end, Danny gave this great guidance (with my highlight):

“The context is safe to keep around as long as you are careful to make sure that it is always used only on a single thread (put it into thread local storage and have one copy for each thread if you need multiple threads).  The connection will open and close automatically as needed so you don’t need to worry about holding a connection open.  Long-running contexts are the expected pattern for rich client appsjust not the right plan for asp.net scenarios and the like where you want the server to be as stateless as possible.”

  Sign up for my newsletter so you don't miss my conference & Pluralsight course announcements!  

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.