locked
Schema Compare Write Updates Creates Duplicates

    Question

  • I have a Test database for practice and got the schema out of sync with the database and wanted to basically refresh the schema against the database by doing a schema compare with the database as source and db proj as target; when I did hte write updates it added the objects again as new objects instead of overwriting the existing tables, views, sproc, etc. 

    2 questions:

    1. Is there a setting that tells the schema write to overwrite existing objects so it doesn't create duplicates?

    2. Is there a quick way to discard a database project and reload the schema from a database instead of doing the schema compare to start fresh again.

    Wednesday, March 21, 2012 7:33 PM

Answers

  • Hello Clu82,

    1). There may be two reasons cause you create duplicated database objects when you write update:

    • These database objects are commanded out in the database project.
    • These database objects are not included during build. That is the Build Action is not "Build".

    To deal with your issue, please first make sure these database objects in the database project are not commanded out, and the Build Action property is set to "Build". Please refer to this case for more information: http://social.msdn.microsoft.com/Forums/en-US/vstsdb/thread/dd18f8be-3432-41ad-a916-15ffd5ad9c7f

    2). Apart from Schema Compare, another option for you synchronize the objects in the source database with the target database project is using Import Script option. With this way, you should first create generate the .sql file in the SSMS. And then right-click the database project in the VS and select the Import Scripts option. You should check theOverwrite objects that already exist in the project checkbox to overwrite the existing objects in the database project.

    Thanks.


    Vicky Song [MSFT]
    MSDN Community Support | Feedback to us

    • Marked as answer by Clu82 Friday, March 23, 2012 5:32 PM
    Thursday, March 22, 2012 3:09 AM
    Moderator

All replies

  • Hello Clu82,

    1). There may be two reasons cause you create duplicated database objects when you write update:

    • These database objects are commanded out in the database project.
    • These database objects are not included during build. That is the Build Action is not "Build".

    To deal with your issue, please first make sure these database objects in the database project are not commanded out, and the Build Action property is set to "Build". Please refer to this case for more information: http://social.msdn.microsoft.com/Forums/en-US/vstsdb/thread/dd18f8be-3432-41ad-a916-15ffd5ad9c7f

    2). Apart from Schema Compare, another option for you synchronize the objects in the source database with the target database project is using Import Script option. With this way, you should first create generate the .sql file in the SSMS. And then right-click the database project in the VS and select the Import Scripts option. You should check theOverwrite objects that already exist in the project checkbox to overwrite the existing objects in the database project.

    Thanks.


    Vicky Song [MSFT]
    MSDN Community Support | Feedback to us

    • Marked as answer by Clu82 Friday, March 23, 2012 5:32 PM
    Thursday, March 22, 2012 3:09 AM
    Moderator
  • I couldn't reproduce this issue when i started from another database project and I also updated to VS2010 SP1 so not sure what the issue was but your info was still helpful!
    Friday, March 23, 2012 5:33 PM