I am trying to use linq to perform CRUD actions against
CRM 2011, all retrieves are working great but I am having some issues creating new records. I can successfully create new
ACCOUNT & OPPORTUNITY records but I am unable to create a
CustomerAddress or Contact record, example code can be seen below:
The Exception is: "EntityState must be set to null, Created (for Create message) or Changed (for Update message)"
Before you ask, yes I have tried setting entity.EntityState = null and entity.EntityState = EntityState.Created
newAddress = newCustomerAddress()
"Test Line 1",
I think you've misunderstood the purpose of Linq to CRM. It's only meant to retrieve data, not create/update/delete. Ultimately it just maps to a queryexpression. Unless there was a major change in direction with the 2011 linq support (which
I haven't seen any mention of anywhere) then compliance rules of CRM still forbid direct data layer updates (even through linq).
Send your C_UD through the CRM SDK.
Proposed As Answer byI am BenWednesday, February 23, 2011 1:10 AM