Child object not creating on update of parent C#

G

goalie05

Guest
I am new to the forum and C# so forgive me for any misunderstandings! Anyhow, since upgrading our product to .net core 3.0 we are having some issues when creating a child record on an update to the parent. The child object is visible on the parent before the update call, however I get the exception after:

"One or more errors occurred. (Database operation expected to affect 1 row(s) but actually affected 0 row(s). Data may have been modified or deleted since entities were loaded."

If I manually create the child record in the db before running the update command the child updates and the parent updates. Please see the update code below:

public async Task UpdateAsync(T entity)
{
_context.Entry(entity).State = EntityState.Modified;
await _context.SaveChangesAsync();
}


Is this exception due to this breaking change? https://github.com/aspnet/EntityFrameworkCore/issues/13552?

Any thoughts on what I would need to change to get the child to be available for the update?

Thanks for the help!

Continue reading...
 
Top