Thursday, September 10, 2015

Ten Reasons to Use SSDT Database Projects.

1.       Schema Compare

Find differences between 2 databases or between database and database project.

In Visual Studio
Go to View -> SQL Server Object Explorer.
Add SQL Server.
Once Server is added, Select a database and choose Schema Compare.






2.     Create a database project. 

Right click on a database and select Create New Project. 
Once the project is created, it can be checked in source control tool (GITS or TFS).


3.       Automated Deployment.

The database project can be published to target database. 

Right click on the database project and select publish. This synchronizes the schema of target database with database project. Any existing data in the target database is retained.




5. Deployment Script Generation.

You can generate a deployment script and examine it before publishing to target database.

Right Click on Database Project, Select Publish and Generate Script. 
The script once generated can be deployed using SSMS.



The Advanced button gives you additional deployment options like Take Backup Before Publish etc.

6.  Snapshot & DACPAC.

 DACPAC is a single database file that contains entire database schema.  When you do not have access to production server, you can generate DACPAC and hand it over to DBA. The DACPAC can be deployed using SSMS "Upgrade Data Tier Application Task".




To create DACPAC right click database project and select "Snapshot Project". This creates DACPAC in snapshots folder of project.



When you do not have source control, DACPAC can be used to capture point in time snapshot or major/minor versions.

7.       Build Time Validation 

Visual studio includes a local debug database, when database project is built, it is deployed to local database, if there are errors (invalid table references for example), they will show up during build time as errors.

8. Automated Testing.


9. Continuous Database Integration.



No comments: