Click here to Skip to main content
Click here to Skip to main content

How to Compare Database Schema in VS 2012, How to Update the Target Database to the Server

, 4 Mar 2013 CPOL
Rate this:
Please Sign up or sign in to vote.
How to compare database schema in VS 2012 and how to update the target database to the server

Introduction

In this article, we will discuss how to compare two database schema step by step and finally how to update the target database to the server.

Background

Many times, we come across situations where there are multiple databases used for development and they are to be brought in sync when the development changes are to be moved to QA/production.

Schema compare tool makes it easy to identify the inconsistencies between the databases. The tool not only highlights the attributes that were modified, but also the exact lines of code that were modified/updated.

Using the Code

Let us open the VS2012 IDE, Go to SQL -> Schema Compare -> New Schema Comparison to open the Schema comparison wizard.

The schema compare takes two inputs:

  • Source: The DB where the changes have already been made and from where the modifications are to be rolled out [usually development DB]
  • Target: The DB that is outdated and where the changes are to be made [usually the production or QA database]

Click to enlarge image

Once we have selected the source, target DB. Click on Compare.

Now we can see the changes in the procedures, schema, table are grouped under Change, and the new added tables, procedures are grouped under Add.

Click to enlarge image

Now once we click on any change, we can see the SQL query changes in the object definitions. Changes are highlighted in different color. We can copy/paste modify the query as we want in the target database.

Whereas in add type, we can click on add symbol. Once you have updated the target script, click on update. A pop up will be shown as below:

Click to enlarge image

Once you click on yes, all changes will be reflected in target DB. Now you can view the script, progress, message as shown in the below image:

Click to enlarge image

Points of Interest

There have been lots of changes when compared to VS2010 schema compare on UI side as well as functionality side, most of it being user friendly.

History

  • 04 March 2013: First version

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Syed Moula Ali
Software Developer
India India
I Started my Programming career with C#. Later got a chance to develop Windows Form applications using C#. Now using C#, WCF, TFS, Entity Framework & Silverlight 5.0 to develop an application, for tagging finance data and generate XBRL files.
 
My interests involves Azure, ASP.NET SPA, SQL Server 2012, .Net 4.5.
Follow on   Twitter

Comments and Discussions

 
QuestionHow best to compare db schemas of multiple DBs in prod environment? Pinmemberchauey16-Sep-13 20:47 
AnswerRe: How best to compare db schemas of multiple DBs in prod environment? PinmemberSyed Moula Ali16-Sep-13 21:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.141216.1 | Last Updated 4 Mar 2013
Article Copyright 2013 by Syed Moula Ali
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid