Try wrapping the database operations around a transaction.
using var transaction = await _context.Database.BeginTransactionAsync();
// rest of your code
await transaction.CommitAsync();
This will make sure that there aren't any concurrency issues or race conditions.