
Hi folks
I'm trying to write a method to handle merging of entities, and one of the requirements (obviously!) is to transfer relationships from the old entity to the new one.
Using the IOrganizationService.Disassociate message works fine for N:1 and 1:N relationships, but for N:N relationships I get a 'Generic SQL Error' message.
Looking deeper into the logs this appears to be a foreign key constraint violation. :
Anyone have any ideas?
Cheers
Dan
[2012-04-25 10:07:40.912] Process: w3wp |Organization:06ae5f18-1ae2-4961-a738-5e0bff891af5 |Thread: 14 |Category: Platform.Sql |User: c1bb7b51-a2da-de11-a51c-00155d015f08 |Level: Error | BusinessProcessObject.ExecuteNonQuery
>Exception when executing non-query: delete from [ccrm_ccrm_interaction_ccrm_servicerequestBase] where ([ccrm_ccrm_interaction_ccrm_servicerequestId] = 'baaca45d-67db-df11-8abc-00155d015f0f') Exception: System.Data.SqlClient.SqlException (0x80131904): The DELETE statement conflicted with the REFERENCE constraint "FK_ccrm_ccrm_interaction_ccrm_servicerequestExtensionBase_ccrm_ccrm_interaction_ccrm_servicerequestBase". The conflict occurred in database "BCBC_MSCRM", table "dbo.ccrm_ccrm_interaction_ccrm_servicerequestExtensionBase", column 'ccrm_ccrm_interaction_ccrm_servicerequestId'.
The statement has been terminated.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at Microsoft.Crm.CrmDbConnection.InternalExecuteWithRetry[TResult](Func`1 ExecuteMethod, IDbCommand command)
at Microsoft.Crm.CrmDbConnection.InternalExecuteNonQuery(IDbCommand command, Boolean capturePerfTrace)
at Microsoft.Crm.CrmDbConnection.ExecuteNonQuery(IDbCommand command, Boolean impersonate, Boolean capturePerfTrace)
at Microsoft.Crm.BusinessEntities.BusinessProcessObject.ExecuteNonQuery(IDbCommand command, ISqlExecutionContext context)
*This post is locked for comments
I have the same question (0)This might be related to the same reason why you can't import N:N entities.