We do have Dynamics CRM 2016 on-prem implementation. There is webapi service which consumes Dynamics Organization service.
On local development environment we do not get any error, but when we deploy it on test or production environment we get ‘Collection was modified; enumeration operation may not execute’ error.
We get this error even for simple retrieve (which does not include any list or entitylist).
Code which returns error
context.Opportunity.FirstOrDefault(d => d.opportunityid == oppId);
context.OrganizationService.Retrieve(incident.EntityLogicalName, incidentId, columnset).ToEntity<incident>()
Any inputs will be highly appreciated.