I'm a little confused on how to approach EF development when looking at all these articles together, since I can't find a sample that addresses all of these practices in one place:
The following article recommends that I create a reusable caching layer for Azure in a repository (but it doesn't implement IDisposable)
This article recommends that the context shouldn't be reused for more than one HTTP query
This article recommends I initialize the context / repository in the constructor, it disposes of the context (repository) by overriding the controller's dispose(). There is no using statement.
This post says that the
Using
block has issues in WCF (link1) (link2) (link3)This post demonstrates an option to use IDisposable with the using block
This post shows an option where MVC applications override Dispose() to get rid of the context
Question
Should I call Dispose? Where should I call it to ensure proper lifetime of the context? ... In an MVC app this seems to be done by overriding the controller's dispose method.
How should I dispose of the Azure cache linked above? ... Perhaps ObjectCache is the only object I should be concerned about.
Should I use Using, or is using untrustworthy?
Should Microsoft produce a sample that addresses all these issues? What would that sample look like? (if it's not this one) Most samples I see with EF + MVC have a varying and inconsistent implementation. I'm not sure who to imitate in my project.