Database Cycle Management is Hard.

Microsoft create SQL Server Data Tools to Visual Studio 2013, to  turn easier the development.

  • 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

STEP1 – Create Project

Select SQL Server Database Project Template and call it DemoSSDT

A empty project will be created.

STEP2 – 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. On this demo we will choose Database, since we have an existent SQL Server Database.

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

Select the option Start

The import will start.

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

STEP3 – Create Table

Create 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.

Create new table on dbo Schema an name it Currency.

The table was created with Id field pre generated.

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.

STEP4 – Refactoring

One of the new features, it’s 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, allow the user to rename in all solution (Functions, Store Procedures…) the field of our table.

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

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

Choose the Publish button.

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

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

Resources

Microsoft SQL Server Data tools – http://msdn.microsoft.com/en-us/data/tools.aspx

VS and SSDT versions – http://blogs.msdn.com/b/ssdt/archive/2014/01/31/ssdt-and-visual-studio-versions.aspx

Team Blog and Forums – http://blogs.msdn.com/b/ssdt