Primary key violation during build


       I am getting a Primary key violation during the build process in Team city.

       Situation is:

         I use Reg gate source control to link one of the static data tables.

        Both my local instance and the target database have  the same data and same number of rows in the table.

       When i commit the change and then push it it triggers the build in Teamcity.

       But the build process stops with an error stating 'cannot insert duplicate values to the table'.Why it should show such an error?.I am just trying to link the table on my local instance DB to the source control.

       Any thoughts on this are much appreciated.

Kind Regards










1 comment
Comment actions Permalink

Hi Mini,

I'm not sure I fully understand your issue. It would probably help if you could share a screenshot of your build configuration.

On the other hand, there are two possibilities that I seem to understand from your problem:
-The error comes from TeamCity's database, trying to insert a bad row because the primary key is duplicated.
-The error comes from your own application, that has its own database, that is synced with your development environment, where it works, but in TeamCity it fails to insert.

If it's the first, we would need more details on what exactly it's trying to insert. The full stacktrace from the log, preferably with some extra lines above and below it for context would be ideal to try and understand exactly when and what happens.

If it's the second, it's going to be really hard for us to help you. You seem to have your own database and that one throws the issue.

If it's none, and it's something to do with the RedGate tools, I would ask you to forward your request (providing as much detail as possible) to them, as their tools might be doing something out of our control.

If you are uncertain, as mentioned for the first case, please send us extra information and context on the exact issue so we are able to understand what is going on.

Also, please take into account that this is the "Hub" forum. It's easier to get answers about TeamCity if you post your questions directly to the TeamCity forums here:


Please sign in to leave a comment.