Will Disabling Entity Tracking For Request Disable entity tracking of other requests made in parallel?

Troydon Luicien 1 Reputation point
2021-10-17T05:45:45.207+00:00

I have an issue with slowness in an application, where I need to loop 800 times and get and then update entities on each iterating. I found that disabling entity tracking using either context.Configuration.AutoDetectChangesEnabled = false or using .AsNoTracking() to resolve, the issue of slowness. This is because the entities appear to get collected into the entity tree history, for each iteration, and use up all the RAM this slowing my app down.

I am just wanting to know if I can call AutoDetectChangesEnabled =false at the start of a loop, then at the end of the loop set it to true. However, I wanted to know if this will end up disabling entity tracking for other requests made in paralell to the app that needs to be tracked, up until this loop ends? Or will the configuration only apply to the current request? I would not be using it within a using statement.

Alternatively, if this does disable for other requests, I was thinking of using .AsNoTracking() however, have issues saving to db because this is a readonly call, and also does not seem to include navigation properties, would I just able to use .Include() statements to include those navigation classes? And how do I go about saving with using no tracking queries.

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,415 questions
{count} votes