Dynamics CRM on-premise: How to delete managed solution
Problem
Issue according to which “Solution XXX cannot be deleted. The following components are required by other components in the system” This type of error occurs.
Warning
This is an unsupported modification to the CRM database and may corrupt it.
Solution
This managed solution can be deleted through applying some queries on database of Dynamics CRM On-Premise. To do that first of all you have to get ID of Solution which we can get either from database or from Dynamics CRM URL. Use following sql query to get solution id from database :
Select SolutionId from SolutionBase where UniqueName='<solution-name-here>'
Now use following queries to remove that particular solution from dynamics crm:
Begin try
Begin Transaction Deletesolution
Delete from SolutionComponentBase where SolutionId='SolutionId Here' --(1)
Delete from SolutionComponentBase where solutioncomponentid in (Select solutioncomponentid from SolutionComponent whereSolutionId='SolutionId Here') --(2)
Delete From DependencyBase where DependentComponentNodeId in (Select DependentComponentNodeId from Dependency whereDependentComponentBaseSolutionId='SolutionId Here') --(3)
Delete from DependencyBase where RequiredComponentNodeId in (Select RequiredComponentNodeId from Dependency whereRequiredComponentBaseSolutionId='SolutionId Here') --(4)
Delete from DependencyNodeBase where BaseSolutionId='SolutionId Here' --(5)
Delete from dependencybase where DependentComponentNodeId in (select dependencynodeid from dependencynode whereTopSolutionId='SolutionId Here') --(6)
Delete from dependencybase where RequiredComponentNodeId in (select dependencynodeid from dependencynode whereTopSolutionId='SolutionId Here') --(7)
Delete from DependencyNodeBase where TopSolutionId='SolutionId Here' --(8)
Delete from SolutionBase where solutionid='SolutionId Here' --(9)
Commit Transaction Deletesolution
End Try
Begin Catch
rollback transaction Deletesolution
End Catch