Frankly I am a newbie in both C# and Asp.net MVC. I also do not know how the asp.net web application actually works on IIS and ASP.NET framework behind the scene.
I am confused with the decision where I have to declare a field of DbContext (or any class derived from DbContext) in my asp.net mvc application.
I have two choices:
- Declare the field as a static field inside
global.asax
such that all controllers can make use of it. - Declare the field as an instance field inside each controller class.
Could you explain which one is the correct one? More detailed explanation is really needed.