Monday, September 24, 2012

AttributeMap with ID Does not exist

First post in almost 3 years!

I will preface this article by saying two things: First, the following procedure is neither recommended or supported by Microsoft or we here at Armanino Consulting and is intended for informational purposes only. Second, we do not take responsibility for the potential damaged to your database that this procedure may cause.

With that said, I was uninstalling some managed solutions when I came across this gem which would not allow me to uninstall the managed solution: Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: attributemap With Id = d1ae5a02-096e-e111-a4fe-000c294e53dd Does Not ExistDetail:

After digging into the SQL tables I located the offending AttributeMapBase row. After taking a backup of the database, I forcefully deleted the row to see what would happen. Unfortunately I received a different error: EntityMap with ID = …. Does not Exist. After restoring the database I took a look at the deleted row and grabbed it’s corresponding EntityMapID. I pulled up that row in the EntityMapBase table. Trying again I deleted both that row and the row from the AttributeMapBase table and attempted to delete the solution again. I received the same error as before but got a different ID this time.

Looking at the ID’s I could see that they were all related to that particular solution so I took a scorched earth approach and wrote a couple of queries to nuke out all of the entitymap entries and attributemap entries for the solution. First thing I did was get the guid of the appropriate solution which is on the AttributeMapBase entry. Then I plugged it into the following two queries:

delete from entitymapbase where EntityMapId in (select distinct entitymapid from AttributeMapBase where SolutionId = 'Insert Solution ID Here')

delete from AttributeMapBase where SolutionId =  'Insert Solution ID Here'

Once the entries were deleted, I was able to successfully delete the solution (although it took longer than normal).

No comments:

Post a Comment