I have gone through many articles but find too less information about the scope of DbContext in window forms applications. So far I have seen following implementations:
1) First Implementation
using(var db=new DbContext())
{
// perform operations
}
2) Second Implementation
public class A
{
private DbContext _db;
public void DoSomething()
{
_db.Students.Find(1);
}
}
3) Third Implementation
Using the Singleton class to initialize the DbContext and call it in whole program/Application
4) Fourth Implementation
Declaring the DbContext in a common or settings class as a static property and Call it in whole project/Application.
So, my question is what is the best implementation of DbContext in an application and why ? And what are the drawbacks of other implementations that are not the best ?