What is the proper way to execute a stored procedure (using the ADO method) in Entity Core?
Should I use the injected dbcontext or should I create a new one?
public class ContactController
{
private readonly MyDbContext _context;
public ContactController(MyDbContext context)
{
_context = context;
}
public IActionResult Search(ContactSearchModel csm, int page)
{
//execute using the injected _context?
using (var command = _context.Database.GetDbConnection().CreateCommand())
{
//...
}
//or create a new context?
using (var newContext = new MyDbContext())
{
using (var command = newContext.Database.GetDbConnection().CreateCommand())
{
//...
}
}
}
}