0

When I try to purge my entity with the Master Data Service interface or with the SP mdm.udpDeletedMembersPurge, I get this error:

MDSERR200221|Members cannot be purged from the model version. It contains at least one entity that is the target of a sync relationship.

Yes, I have implemented some entity Sync, and when I run them manually, it doesn't solve the problem.

Any idea?

Panagiotis Kanavos
  • 120,703
  • 13
  • 188
  • 236
Gaë
  • 1
  • 2

2 Answers2

0

There is a check in the mdm.udpDeletedMembersPurge stored procedure to ensure that you are not trying to purge a sync entity. It does not specify the entity you are trying to purge, so any sync entity in your current model will prevent a purge.

I modified the store procedure to look at the current entity by adding another clause to the predicate: This code starts at line 172.

-- Verify the entity is not a sync target.
DECLARE @TargetEntityName NVARCHAR(50) = NULL;
SELECT TOP 1 
    @TargetEntityName = e.Name
FROM mdm.tblSyncRelationship sr
INNER JOIN mdm.tblEntity e
ON sr.TargetEntity_ID = e.ID
WHERE   e.Model_ID = @Model_ID
    AND sr.TargetVersion_ID = @Version_ID
    AND e.id = @Entity_ID --Add this to the predicate
stanorama
  • 26
  • 6
0

Similar to the other answer, I added a condition using the following, slightly altered version. This will still correctly throw the error if you try to execute the procedure against an entire model, without defining an entity, where the model contains a sync target.

-- Verify the entity is not a sync target.
DECLARE @TargetEntityName NVARCHAR(50) = NULL;
SELECT TOP 1 
    @TargetEntityName = e.Name
FROM mdm.tblSyncRelationship sr
INNER JOIN mdm.tblEntity e
ON sr.TargetEntity_ID = e.ID
WHERE   e.Model_ID = @Model_ID
    AND sr.TargetVersion_ID = @Version_ID
    AND (@Entity_ID IS NULL OR e.ID = @Entity_ID);  --Added line