Search code examples
dynamics-crmmicrosoft-dynamicsdynamics-crm-2015

Error when importing solution containing relationship with Hierarchical=Yes: Index or statistics already exists


I cannot import a solution containing a relationship set to Hierarchical=Yes. If I change the relationship to Hierarchical=No the import works just fine.

The issue occurs when an unmanaged solution containing only the Contact entity with Hierarchical=Yes set on a custom relationship is imported to a target environment. No errors are shown in the log.

Further debugging shows that it is not possible to change the same relationship to Hierarchical=Yes in the affected target environments, because it fails with:

A SQL Server error occurred

Tracing on the server reveals that:

The operation failed because an index or statistics with name 'ndx_for_cascaderelationship_publisher_relationshipname' already exists on table 'ContactBase'.

I can confirm that the index indeed already exists in the table. We have not created any indexes in the database ourselves.


Solution

  • You can resolve this issue by:

    1. Setting the affected relationship to Can be customized: False in the source environment (don't ask - Microsoft works in mysterious ways...).
    2. Importing the solution to the target environment.

    This works even if you are deploying unmanaged solutions.