I am building a statistics (multi-agents) application, I'm using EF5 to retrive a list of agents from agents table. it's a very large amount of data (arround 50 000 agents per region) needed to be loaded at a time to proceed some immigration logic on them. I found that the (Region).Agents navigation property is very very slow to load, but, executing the same query takes just 1 sec on Sql server. and the foreach too takes a considerable time looping.
foreach (OrigineAgent origineAgent in new List<Agent> Origine.Agents.AsParallel()))
{
origineAgent.ScoreCalculator = _container.Resolve<IScoreCalculator>();
origineAgent.AgentExoVariables = AgentVars;
_migrationManager.Migrate(origineAgent);
}
What do I have to do to increase data loading and looping performance?