C# 从CRM 2015值中删除EntityReference

C# 从CRM 2015值中删除EntityReference,c#,crm,entityreference,dynamics-crm-2015,C#,Crm,Entityreference,Dynamics Crm 2015,我正在做一个工具来同步CRM和另一个应用程序之间的一些数据。 现在我必须从EntityReference中删除该值。我试着这样做: contact.ParentCustomerId = null; contact.ParentCustomerId = new EntityReference(Crm.Context.Account.EntityLogicalName, Guid.Empty); 但它不起作用。这并没有给我任何错误,但当我通过浏览器进入CRM时,该字段仍然是有价值的。 我也试过这

我正在做一个工具来同步CRM和另一个应用程序之间的一些数据。 现在我必须从EntityReference中删除该值。我试着这样做:

contact.ParentCustomerId = null;
contact.ParentCustomerId = new EntityReference(Crm.Context.Account.EntityLogicalName, Guid.Empty);
但它不起作用。这并没有给我任何错误,但当我通过浏览器进入CRM时,该字段仍然是有价值的。 我也试过这样做:

contact.ParentCustomerId = null;
contact.ParentCustomerId = new EntityReference(Crm.Context.Account.EntityLogicalName, Guid.Empty);
但这给了我一个运行时错误

我怎样才能解决这个问题?多谢各位

更新:

 Crm.Context.Contact contatto = ContattiTOA.Transform(c, account); //Inside the transform you can see that line of code I posted before..

 var entityToUpdate = this._context
                                .ContactSet
                                .Where(cont => cont.new_SIP_id == contatto.new_SIP_id || cont.Id == contatto.Id)
                                .First();

        if (entityToUpdate.new_SynchronizewithSIP.HasValue && entityToUpdate.new_SynchronizewithSIP.Value == true)
        {
            contatto.Id = entityToUpdate.Id;
            contatto.OwnerId = entityToUpdate.OwnerId;
            contatto.EntityState = EntityState.Changed;

            request = new UpdateRequest { Target = contatto };
        }

        requests.Requests.Add(request);

        ExecuteMultipleResponse responses = (ExecuteMultipleResponse)this._context.Execute(requests);

        foreach (var responseItem in responses.Responses)
        {
            if (responseItem.Fault != null)
            {
                ... // I never fall in here
            }
        }

contact.ParentCustomerId=null;是正确的,之后是否保存记录?是的。。。所有其他字段都已正确更改。。。但不是那个…我同意这行代码是正确的,所以这个错误可能是在其他地方。我已经做了一些更新,所以你可以看到所有的代码。。。我做了一个调试,一切似乎都是正确的…在你发布的代码中,我没有看到行
contact.ParentCustomerId