An error occurred when communicating with Dataverse.
Detailed description: Unable to cast object of type 'Microsoft.Xrm.Sdk.Entity' to type 'Microsoft.Xrm.Sdk.EntityReference'.

Hi Ahsan,
Thanks for sharing the details! The error you're encountering:
"Unable to cast object of type 'Microsoft.Xrm.Sdk.Entity' to type 'Microsoft.Xrm.Sdk.EntityReference'"
typically occurs when a field in the Dataverse entity is expected to be a lookup (EntityReference) but is instead being treated as a full Entity object.
Check Field Mappings:
CUSTOMER table.PrimaryContactId, OwnerId, etc.).Review the Target Dataverse Schema:
EntityReference, not a full Entity.Update or Remove Problematic Mappings:
Use Logging and Debugging:
Check for Customizations:
If the issue persists, consider raising a support ticket with Microsoft and include the full mapping configuration and error trace.
Hope this helps!
Please mark this response as helpful if it answered your question.
Best regards!