I am new in Entity framework core, I am making a simple short project. In my project I use trigger. But when deleting multiple items, the trigger shows an error : "Invalid attempt to call ReadAsync when reader is closed”.
I googled a lot but was unable to find any solution in this situation. How can I solve this problem?
Below is my code :
Triggers<Items>.Deleted += async e => {
decimal convertedQuantity = e.Entity.MeasurementUnitSetup.ConversionRatio * e.Entity.IssuedQuantity;
var warehouseItem = e.Context.Entry(e.Entity.Warehouse).Collection(o => o.WarehouseItems)
.Query()
.SingleOrDefault(wi => wi.WarehouseId == e.Entity.WarehouseId && wi.MeasurementUnitSetup.ItemId == e.Entity.MeasurementUnitSetup.ItemId);
if (warehouseItem.Quantity - convertedQuantity >= 0)
warehouseItem.Quantity -= convertedQuantity;
await e.Context.SaveChangesAsync(); //From here error showing
}
Thanks in advance.