早期绑定实体 类 dynamics CRM 2011,更新或删除时出错

early bound entity classes dynamics CRM 2011, Error while updating or deleting

我现在使用 CrmScUtil 创建 CrmProxy class,当我尝试使用它时遇到了一些问题。

创建联系人工作正常,但更新和删除只会抛出此错误:

{"An error occured while processing this request."}

在 Microsoft.Xrm.Sdk.Client.OrganizationServiceContext.SaveChanges(SaveChangesOptions 选项) 在 Microsoft.Xrm.Sdk.Client.OrganizationServiceContext.SaveChanges()

你能告诉我我做错了什么吗?查询有效 returns 我正在尝试的联系人数据 update/delete。

OrganizationServiceProxy 组织服务; orgserv = new OrganizationServiceProxy(orgConfigInfo, clientCreds); orgserv.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(新的 ProxyTypesBehavior());

        //Create            
        using (var context = new XrmContext(orgserv))
        {
            Contact contact = new Contact()
            {
                FirstName = "fName",
                LastName = "lName",
                Address1_Line1 = "Address1_Line1",
                Address1_City = "Address1_City",
                Address1_StateOrProvince = "XX",
                Address1_PostalCode = "00000",
                Telephone1 = "(000) 000-0000",
                JobTitle = "JobTitle",
                Company = "Company",
                EMailAddress1 = "test@test.com"
            };
            context.AddObject(contact);
            context.SaveChanges();
        }
        //End Create

        //Update
        using (var contextUpdate = new XrmContext(orgserv))
        {
            try
            {
                Contact con = contextUpdate.ContactSet.FirstOrDefault(c => c.EMailAddress1 == "test@test.com");
                if (con != null)
                {
                    con.Fax = "Fax132456";
                    contextUpdate.UpdateObject(con);
                    contextUpdate.SaveChanges();
                }
            }
            catch (Exception ex)
            {

            }
        }
        //End Update


        //Delete
        using (var contextDelete = new XrmContext(orgserv))
        {
            Contact con = contextDelete.ContactSet.FirstOrDefault(c => c.EMailAddress1 == "test@test.com");
            if (con != null)
            {
                contextDelete.DeleteObject(con);
                contextDelete.SaveChanges();
            }
        }
        //End Delete

我找到了这个问题的答案,希望对您有所帮助:

最新的 CoreAssamblies (7.1.0) 似乎存在错误

所以关键是卸载 NuGet 包并安装 7.0.0

安装包 Microsoft.CrmSdk.CoreAssemblies - 版本 7.0.0

之后就没有问题了。