Problem: Last week I a had to clean up a crm-system. So I had to delete a lot of fields and also entities. Deleting a custom entity caused the famous error “Generic SQL error.” After enablig the trace on the crm-server I got some more details:
>Crm Exception: Message: Generic SQL error., ErrorCode: -2147204784, InnerException: System.Data.SqlClient.SqlException (0x80131904): The DELETE statement conflicted with the SAME TABLE REFERENCE constraint "solutioncomponent_parent_solutioncomponent". The conflict occurred in database "ORG_MSCRM", table "dbo.SolutionComponentBase", column 'RootSolutionComponentId'.
Solution: After some googling and try outs, i realized that other solutions were still containing the entity. After removing the entity of all solutions (there were two more) I was able to delete the custom entity.