I am trying to create a new record in Dynamics CRM using C#.
Below is the code that I am using:
Entity Record = new Entity("new_edRecord");
Record["new_year"] = "2100";
Record["new_school"] = new EntityReference("new_school",new Guid("8ba53949-3947-e445-876c-001dd8b71c19"));
Record["new_gradelevel"] = "100000018";
organizationProxy.Create(Record);
When I execute this, I get the below error:
Unexpected exception from plug-in (Execute): Department.EdRecord.RecordCreate: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
I double checked to see if a school exist with the GUID by visiting the below url:
https://crm.site.com/orgname/api/data/v8.0/new_schools(8ba53949-3947-e445-876c-001dd8b71c19)
and this brought a result. Not sure what I am missing here.
Record["new_year"] = "2100"
but I'm assuming that should be "2010"? You should try to generate strong classes using the CrmSvcUtil tool – jasonscript