In the new MVC Core it seems the standard way to get the context to the controller is by doing this
public class BaseController : Controller
{
public readonly ReportDBContext _db;
public BaseController(ReportDBContext db)
{
_db = db;
}
}
I can then use
public class HomeController : BaseController
{
public HomeController(ReportDBContext db) : base(db) { }
}
To make this a little easier in all other controllers.
Normally in Asp.net MVC I can get a context any time by using new ReportDBContext()
Is there a similar way of this now, or do I have to have the context in all controllers in asp.core MVC?