Share via

Every time we are trying to deploy this to from Power Platform DEV to QA or PROD Env. we are having this issue with Unique Key constraint.

Krupesh Patel 0 Reputation points
2024-08-29T16:11:25.66+00:00

Every time we are trying to deploy this to from Power Platform DEV to QA or PROD Env. we are having this issue with Unique Key constraint.. We created the New Env. Variable to see if that Fixed this issue but it's caused the same error when we tried to redeploy the same solution again to same env. We have few enhancements to current applications.

ImportAsHolding failed with exception :Cannot insert duplicate key exception when executing non-query: System.Data.SqlClient.SqlCommand Exception: System.Data.SqlClient.SqlException (0x80131904): Violation of UNIQUE KEY constraint 'ndx_envvarval_schemaname'. Cannot insert duplicate key in object 'dbo.EnvironmentVariableValueBase'. The duplicate key value is (kpapps_HuntAppsSPSite, 0, Jan 1 1900 12:00AM). The statement has been terminated. at Microsoft.Crm.CrmDbConnection.HandleExecutionExceptionAbstract(Exception exception, String commandText, IDbConnection connection, IDbCommand command, IDbTransaction transaction, Boolean isOpen, Int32 commandTimeout, IConnectionRetryPolicy localRetryPolicy, Int32& retryCount) at Microsoft.Crm.CrmDbConnection.InternalExecuteWithRetryAbstract[TResult] at Microsoft.Crm.CrmDbConnection.<>c__DisplayClass238_0.

Community Center | Not monitored
0 comments No comments

3 answers

Sort by: Most helpful
  1. Thoman, Nick 61 Reputation points
    2024-09-24T17:54:07.9066667+00:00

    Go to the environment you want to deploy to. Go to the Solutions section in Power Apps. Then open up the Default Solution. In the LONG list look for Environment Variables. In there select your variable 'kpapps_HuntAppsSPSite'. Delete the default value and remove delete the current value in the environment. Then deploy again. It should clean up that duplicate value issue. Also on your environment variable in DEV. Uncheck that toggle to export the current value.

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments

  2. Anonymous
    2024-08-29T17:00:14.9033333+00:00

    Hi Krupesh Patel,

    Thank you for reaching out to us on the Microsoft Q&A forum.

    This topic is currently not supported in the Q&A forums.

    I recommend initiating a new discussion through the Power Automate Community platform Moderators are readily available there to assist you and provide guidance.

    Please don't forget to Accept helpful answer and close this thread.

    Was this answer helpful?

    0 comments No comments

  3. Aryaman Gupta 0 Reputation points
    2024-08-29T16:57:02.0433333+00:00

    Here are a few steps you can take to troubleshoot and resolve this issue:

    1. Check for Duplicate Keys: Ensure no duplicate keys are in your data. You might need to clean up the data in your source environment before deploying.
    2. Review Environment Variables: Double-check that the variable names and values are unique and correctly configured since you mentioned creating a new environment variable.

    Update Schema: If the issue persists, consider updating the schema to handle duplicates more gracefully. This might involve changing the unique constraints or modifying the data model.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.