首页 > 解决方案 > Azure 数据工厂复制数据 - 无法将“System.String”转换为目标类型“Microsoft.Xrm.Sdk.EntityReference”

问题描述

我正在尝试在 Azure 数据工厂的复制数据操作中设置查找字段。

我得到的错误是

Failure happened on 'Sink' side. ErrorCode=UserErrorTypeConversionFail,'Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,
Message=,Source=,''Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,Message=The 
attribute 'ks_supervisor' with value 'E3BEFA28-C7A6-EA11-A812-000D3A1BB8EF' cannot be converted from 
original type 'System.String' to target type 'Microsoft.Xrm.Sdk.EntityReference'.,Source=Microsoft.DataTransfer.ClientLibrary.DynamicsPlugin,''Type=Sy
stem.InvalidCastException,Message=Specified cast is not 
valid.,Source=Microsoft.DataTransfer.ClientLibrary.DynamicsPlugin,''Type=Microsoft.DataTransfer.Common.Sh
ared.HybridDeliveryException,Message=The attribute 'ks_supervisor' with value 'E3BEFA28-C7A6-EA11-A812-
000D3A1BB8EF' cannot be converted from original type 'System.String' to target type 
'Microsoft.Xrm.Sdk.EntityReference'.,Source=Microsoft.DataTransfer.ClientLibrary.DynamicsPlugin,''Type=Sy
stem.InvalidCastException,Message=Specified cast is not 
valid.,Source=Microsoft.DataTransfer.ClientLibrary.DynamicsPlugin,

关键部分是value 'E3BEFA28-C7A6-EA11-A812-000D3A1BB8EF' cannot be converted from original type 'System.String' to target type 'Microsoft.Xrm.Sdk.EntityReference'

我的问题是如何在 D365/CDS/CRM 中设置查找字段值,如果它期望 EntityReference 类型的值?

我尝试了 CDS 连接器、Dynamics 365 和 CRM 连接器,但都导致相同的错误。我还寻找尝试将源值从字符串转换为 GUID 的方法,但我找不到方法,我不知道这是否会有所帮助,因为它是 GUID 而不是 EntityReference。源列来自“uniqueidentifier”类型的 SQL 表,但它会自动投影到字符串。

标签: azure-data-factory

解决方案


我必须将“@EntityReference”添加到列映射中的目标列名。在此处查看 MSFT 提供的答案:https ://docs.microsoft.com/en-us/answers/questions/34069/azure-data-factory-copy-data-to-cds-cannot-convert.html?childToView= 34732#comment-34732

请参阅此处设置查阅列值的文档。它还显示了如何设置客户列值:https ://docs.microsoft.com/en-us/azure/data-factory/connector-dynamics-crm-office-365#writing-data-to-lookup-field


推荐阅读