Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Dynamics 365 general forum

Solution Import Failure - Cannot insert duplicate key exception when executing non-query

(0) ShareShare
ReportReport
Posted on by 675

Hello Friends,

I am trying to deploy managed solution on a server. But we are getting this error. Anyone can shed some light on it please.

Cannot insert duplicate key exception when executing non-query: System.Data.SqlClient.SqlCommand Exception: System.Data.SqlClient.SqlException (0x80131904): Violation of PRIMARY KEY constraint 'cndx_PrimaryKey_pluginassembly'.
Cannot insert duplicate key in object 'dbo.PluginAssemblyBase'.
The duplicate key value is (d74b5266-cb11-e411-940f-0050568236f9, 4d2bc929-93e1-481c-9a10-e2f44407924d, 0, Jan 1 1900 12:00AM).
The statement has been terminated.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at Microsoft.Crm.CrmDbConnection.InternalExecuteWithRetry[TResult](Func`1 ExecuteMethod, IDbCommand command, Boolean isReader)
at Microsoft.Crm.CrmDbConnection.InternalExecuteNonQuery(IDbCommand command, Boolean capturePerfTrace)
at Microsoft.Crm.BusinessEntities.BusinessProcessObject.ExecuteNonQuery(IDbCommand command, ISqlExecutionContext context)
at Microsoft.Crm.Platform.SolutionAwareComponents.CreateInstanceActionBase.ExecuteCreate(IDbCommand command, ExecutionContext context)
ClientConnectionId:3d84796a-5256-4117-bc15-3d10405df999
Error Number:2627,State:1,Class:14

Thanks,
Prashant

  • VPrashant Profile Picture
    VPrashant 675 on at
    RE: Solution Import Failure - Cannot insert duplicate key exception when executing non-query

    Can't.

    Experiencing different errors now.

    1. Cannot insert duplicate key exception when executing non-query: System.Data.SqlClient.SqlCommand Exception: System.Data.SqlClient.SqlException (0x80131904): Violation of PRIMARY KEY constraint

    'cndx_PrimaryKey_pluginassembly'. Cannot insert duplicate key in object 'dbo.PluginAssemblyBase'. The duplicate key value is (d74b5266-cb11-e411-940f-0050568236f9, fd140aae-4df4-11dd-bd17-0019b9312238, 0, Jan  1 1900 12:00AM).

    The statement has been terminated.  

    2. Workflow contains an invalid custom activity.

    Also in AssemblyInfo.cs the version was changed to 19.1.0.0. It should not have been changed and should be 1.0.0.0. but couldn't get ahead of this. Trying many ways can't go thru it.

    -Prashant

  • Dynamics365 Rocker Profile Picture
    Dynamics365 Rocker 7,755 on at
    RE: Solution Import Failure - Cannot insert duplicate key exception when executing non-query

    Try same trick on it as well.

  • VPrashant Profile Picture
    VPrashant 675 on at
    RE: Solution Import Failure - Cannot insert duplicate key exception when executing non-query

    Well Dynamics365 Rocker,

    I have move on to next error now. and that is this :

    Crm Exception: Message: Plugin Assemblies import: FAILURE. Error: Plugin: Crm.Packages.WorkFlows, Version=19.1.21.0, Culture=neutral, PublicKeyToken=3c426c5a37eb4f47 of PluginTypeName: Microsoft.Crm.Entities.PluginType and PluginTypeNode: System.Xml.XmlElement caused an exception., ErrorCode: -2147188685, InnerException: Microsoft.Crm.Tools.ImportExportPublish.ImportSolutionException: Plugin Assemblies import: FAILURE. Error: Plugin: Crm.Packages.WorkFlows, Version=19.1.21.0, Culture=neutral, PublicKeyToken=3c426c5a37eb4f47 of PluginTypeName: Microsoft.Crm.Entities.PluginType and PluginTypeNode: System.Xml.XmlElement caused an exception. ---> Microsoft.Crm.Tools.ImportExportPublish.ImportPluginTypesException: Plugin Types import: FAILURE. Error: Plugin: Crm.Packages.WorkFlows, Version=19.1.21.0, Culture=neutral, PublicKeyToken=3c426c5a37eb4f47 of PluginTypeName: Microsoft.Crm.Entities.PluginType and PluginTypeNode: System.Xml.XmlElement caused an exception. ---> Microsoft.Crm.CrmException: Crm Internal Exception: Singleton Retrieve Query should not return more than 1 record. Query: select

    "plugintype0".PluginTypeId as "plugintypeid"

    , "plugintype0".SolutionId as "solutionid"

    , "plugintype0".OrganizationId as "organizationid"

    , convert(bigint, "plugintype0".VersionNumber) as "versionnumber"

    from

    PluginType as "plugintype0"

    where

    ("plugintype0".PluginTypeId = @PluginTypeId0)

    I am not able to go ahead in this workflow thing now.

    I am very near to solution it seems.

    Kindly help.

    Prashant

  • Suggested answer
    Dynamics365 Rocker Profile Picture
    Dynamics365 Rocker 7,755 on at
    RE: Solution Import Failure - Cannot insert duplicate key exception when executing non-query

    It seems you have updated a plugin name or deleted a plugin.

    if you did it then you have to delete assembly and messages from target environment before importing managed solution. Thanks

  • VPrashant Profile Picture
    VPrashant 675 on at
    RE: Solution Import Failure - Cannot insert duplicate key exception when executing non-query

    Any replies CRM gurus ? I am stuck on it.

  • VPrashant Profile Picture
    VPrashant 675 on at
    RE: Solution Import Failure - Cannot insert duplicate key exception when executing non-query

    Thanks Rhett for replying.

    Yeah. but how to find that plugin which is creating the problem. I have also checked the customizations file. Can you give me some pointers to eradicate this issue.

    -Prashant

  • Rhett Clinton Profile Picture
    Rhett Clinton Moderator on at
    RE: Solution Import Failure - Cannot insert duplicate key exception when executing non-query

    This is suggesting you have an existing plugin in the target system with the same plugin Guid ID as the one you are importing but it is not the same plugin.

  • VPrashant Profile Picture
    VPrashant 675 on at
    RE: Solution Import Failure - Cannot insert duplicate key exception when executing non-query

    This is what I am getting after some unsuccessful trials.

    Plugin Types import: FAILURE. Error: Plugin: Crm.Packages.Plugins, Version=19.1.21.0, Culture=neutral, PublicKeyToken=3c426c5a37eb4f47 of PluginTypeName: Microsoft.Crm.Entities.PluginType and PluginTypeNode: System.Xml.XmlElement caused an exception.

    Any ideas?

    Prashant

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,432 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans