In most cases, when I work with an object associated with a database, I work as follows:
// Declare a private static variable of my database
private static BlueBerry_MTGEntities mDb = new BlueBerry_MTGEntities();
Then in any method (example):
public StoreInfo GetStoreByID(int _storeID)
{
using (mDb = new BlueBerry_MTGEntities())
{
mDb.Database.Connection.Open();
}
}
Is it good practice to work in such a way as to avoid failures during failures and to develop an effective MVC Asp.Net application? If not, what will be good practices and how will you do it?
source
share