Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3936602
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T23:58:04+00:00 2026-05-19T23:58:04+00:00

I am using VS 2010 Premium RTMRel (10.0.30319.1) and SS2008. I have a database

  • 0

I am using VS 2010 Premium RTMRel (10.0.30319.1) and SS2008. I have a database which builds AOK and has a post deployment script which loads some sample data. When I build and deploy this DB via the VS UI, it works just fine. When I try to deploy it via vsdbcmd, it fails on the data population with errors like this:

** * SQL01268 C:\source\mydatabase.sql (5197,0) .Net SqlClient Data Provider: Msg 2627, Level 14, State 1, Line 227 Violation of PRIMARY KEY constraint ‘pk_customers’. Cannot insert duplicate key in object ‘dbo.customers’.**

For demo purposes, I am trying to populate a specific record into the customers table and am overriding the IDENTITY property of the id column to set a value of my choosing. The relevant lines in my post-deployment script are these:

SET IDENTITY_INSERT [dbo].[customers] ON
INSERT INTO [dbo].[customers] ([id], [name], [notes]) VALUES ( 10001, N'ABC Co', NULL )
SET IDENTITY_INSERT [dbo].[customers] OFF

Does anyone know why I can override the IDENTITY column (by using SET IDENTITY INSERT ON) via the UI, but not via the command line?

And no, there is no possibility that there is already a record in the customers table with id = 10001. There are no other records (or inserts) in the table at all.

I believe that the “duplicate key in object” part of the error message is just completely wrong, and that it is objecting to me trying to put my own value into the PK column.

The PK constraint has the standard defaults. If I change the defaults and set IGNORE_DUP_KEY = ON, then the command line deploy works. But I don’t want to have to do that.

Any insights or suggestions appreciated.

  • 1 1 Answer
  • 2 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T23:58:04+00:00Added an answer on May 19, 2026 at 11:58 pm

    OK, embarassing.

    It turned out that my post-deployment script had a USE statement that was specifying the default DB name (call it MobileDB). When I was building via the UI, I was also using this MobileDB name, the deployment configuration was always re-creating the database, and so everything worked fine.

    However when I deployed from vsdbcmd I was using a random DB name (like ChickenSoup). So when the data population script ran it was trying to write back to MobileDB, hitting the data that was already there, and failing with a violation of a PK constraint.

    Classic User Error.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have HTML view using 2010 .NET, which I am generating in the report
im using vb 2010 express edition. I have a database (Sql) and a table
Using TFS 2010. I have created a number of new Build Definitions. I also
I am using Visual Studio 2010 Premium version When I run the profiler, it
I have a C# solution which has 2 projects in it and I need
We are currently using Visual Studio 2010 Premium with TFS 2010. Every developer that
I have a weird problem with VS 2010 (Premium). just reinstalled it added the
Using Word 2010 GUI, there is an option to Insert text from file..., which
Using Delphi 2010... I have a set of binary properties I want to group
Im using VS 2010 & EF 3.5. I've imported a stored procedure which returns

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.