I'm using ASP.NET MVC Core 1.1 with VS2015. I would like to understand the following in a portion of my controller code: The last line of the following code gives the error: There is already an open DataReader associated with this Command which must be closed first.
. But if I change SaveChangesAsync()
to SaveChanges()
code works fine.
Snapshot of Controller:
public IActionResult myActionMethod(...)
{
...
var oRecToUpdate = _context.Order.Where(c => c.OrdersId == 104).SingleOrDefault();
if (oRecToUpdate != null)
{
oRecToUpdate.Price = 98.09;
_context.SaveChangesAsync();
}
string sStateNumer = _context.StateNames
.Where(s => s.State == "myState").Select(t => t.StateNumber).SingleOrDefault();
....
}