I am developing an MVC3 application and have been wondering about the following. Should the Entity Framework object (DbContext object) be disposed before passing data to the view?
The obvious issue with this is you will not be able to drill down into the foreign key relations.
Is there a performance hit by doing this?
Yes you absolutely should dispose of the context
The performance hit should be minimal . Any object that can be disposed of should be disposed of ALWAYS.
Dependency injection can free you from having to worry about calling it if done properly as the DI framework will dispose of it for you if instructed.