Skip to content

RC2 ForEachAsync does not work anymore #5440

@bragma

Description

@bragma

Hi,
I've just updated to RC2 and some of my tests are failing. It seems that this sample code using ForEachAsync is not working anymore:

await _dbContext.Stuff.Where(s => s.OtherId== otherId).ForEachAsync(s =>
{
    s.OtherId = defaultId;
});

The exception message is "New transaction is not allowed because there are other threads running in the session." when executing "SaveChangesAsync()"

My workaround at the moment is to materialize the results in a list and then use a foreach:

var listOfStuff = await _dbContext.Stuff.Where(s => s.OtherId== otherId).ToListAsync();
foreach(var s in listOfStuff)
{
    s.OtherId = defaultId;
}

Am I doing something wrong with ForEachAsync?
Thanks!

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions