Click here to Skip to main content
15,881,248 members
Articles / Database Development
Tip/Trick

SQL Server Data Tools to Visual Studio 2013 - Database Reverse Engineering

Rate me:
Please Sign up or sign in to vote.
4.79/5 (6 votes)
30 Oct 2015CPOL3 min read 15.4K   6   2
SQL Server Data Tools to Visual Studio 2013 - Database Reverse Engineering

Introduction

Database Cycle Management is hard.

Microsoft created SQL Server Data Tools for Visual Studio 2013, to make development easier.

  • Single Tool to support developer’s needs
  • Can build, debug, test, maintain, and refactor databases
  • Developers can use familiar Visual Studio tools for database development
    • Code navigation, IntelliSense, C# language, platform-specific validation
      • Debugging, and declarative editing in the Transact-SQL editor
  • Works connected or disconnected (Tools work on top of design time)
  • Have Schema Model differencing capabilities (Compare and Update Model)
  • Schema and app under TFS control
  • Publish to all supported SQL platforms

STEP 1 - Create Project

Select SQL Server Database Project Template and call it DemoSSDT.

An empty project will be created.

Image 1

STEP 2 - Import Database

After the project creation, we need to import from our SQL Server database.

Select the project and with the right mouse button, select the option Import. The import could be made from three different options. In this demo, we will choose Database, since we have an existent SQL Server Database.

Image 2

A new screen will appear to select existent database. In this demo, we use the AdventureWorks2012.

Select the option Start.

Image 3

The import will start.

Image 4

After the import finishes, as we can see, all the schemas from our SQL Server database were imported to our Visual Studio project.

Image 5

STEP 3 - Create Table

Create a new table on DBO Schema call Currency.

Select Add New Item on project solution.

This option will open a new screen with several items divided from categories.

Select the category Tables and Views and choose the option Table. Call it Currency.

Image 6

Create a new table on DBO Schema an name it Currency.

The table was created with Id field pre generated.

Image 7

Create two new fields (Code and Description).

For that on the table designer add two new fields, like in the SQL Server. As you see, the script is automatically created, when we change the designer.

STEP 4 - Refactoring

One of the new features is the possibility to use refactoring.

Select one field on the script tab and with the right mouse button, select the option refactor like on the image below. One of the options is the Refactor option. This option like on the other Visual Studio Project, allows the user to rename in all solution (Functions, Store Procedures, …) the field of our table.

Image 8

STEP5 - Publish

After all our changes on the project, we could in an easy way Publish to SQL Server database the changes made on our project.

Select the project and select the option Publish.

Image 9

Select the target database. On our case will be the AdventureWorks2012 existent on SQL Server database.

Choose the Publish button.

Image 10

On the output window, we have access to result of our publish. One of the options give access to the script generated. If we click on it, we will see the script generated like we see in the image below.

Image 11

On the left tab, as we can see, the Currency table was published to our database, with the three fields created.

Image 12

References

License

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


Written By
Software Developer (Senior) Devscope
Portugal Portugal
I am João Sousa, and since i finish my degree I’m working in software development using Microsoft technologies.

I was awarded

Microsoft Most Valuable Professional (MVP) 2015 – .Net

My profissional profile:

Azure Developer
.NET Developer

My Certifications:

MCTS - .NET Framework - Application Development Foundation
MCTS - .NET Framework 2.0 - Windows-based Client Development
MCTS - .NET Framework 3.5 ADO.NET Applications
MCTS - .NET Framework 3.5 ASP.NET Applications
MCSD - Programming in HTML5 with JavaScript and CSS3
MCSD - Developing ASP.NET MVC 4 Web Applications
MCSD - Developing Windows Azure and Web Services
MCSA Office 365 - Managing Office 365 Identities and Requirements
MCSA Office 365 - Enabling Office 365 Services
MCSD - Implementing Microsoft Azure Infrastructure Solutions

Comments and Discussions

 
GeneralMy vote of 5 Pin
Humayun Kabir Mamun2-Nov-15 19:23
Humayun Kabir Mamun2-Nov-15 19:23 
Questiondeployment Pin
kiquenet.com2-Nov-15 11:11
professionalkiquenet.com2-Nov-15 11:11 

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

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