We created environment variables in our solution, and export and import the solution.
It used to work fine with ALM tasks, and apply different values for env vars using `DeploymentSettingsFile`.
But from time to time, we got error as below:
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 (xxxx, 0, Jan 1 1900 12:00AM).
The fact is, we do not have any duplicated env vars in our solution and they were created a couple of months ago. All of a sudden, we got the above error during importing.
I figured out a workaround as delete the complaining env vars in the development environment, then re-create them with the same name and values, everything works again.
It happened once in July and came up again recently.
Really appreciate if anyone could help out with the root cause. I can provide the ALM pipeline task error details if needed.
Thanks,
Wei