managing database project with visual studio ssdt and tfs
DESCRIPTION
Managing database project with Visual Studio SSDT and TFSTRANSCRIPT
![Page 1: Managing database project with Visual Studio SSDT and TFS](https://reader033.vdocuments.mx/reader033/viewer/2022052910/559b7e121a28ab04768b45db/html5/thumbnails/1.jpg)
Managing Database Project with Visual Studio, SSDT
and TFS
![Page 2: Managing database project with Visual Studio SSDT and TFS](https://reader033.vdocuments.mx/reader033/viewer/2022052910/559b7e121a28ab04768b45db/html5/thumbnails/2.jpg)
About myself:
• Seasoned data architect/DBA with 15 years of SQL Server experience
• Independent consultant, currently Technical Delivery Manager at
Government of Alberta
• Microsoft Certified System Engineer: MCSE
• Oracle Certified Professional: Oracle DBA
• IBM Certified Solution Expert: DB2 UDB
http://netdbsolutions.com
https://twitter.com/HarryZheng
http://ca.linkedin.com/in/harryzheng
https://www.facebook.com/Harry.H.Zheng
2
![Page 3: Managing database project with Visual Studio SSDT and TFS](https://reader033.vdocuments.mx/reader033/viewer/2022052910/559b7e121a28ab04768b45db/html5/thumbnails/3.jpg)
Session agenda
1. Evolution of SSDT
2. Create a database project with Visual Studio / SSDT
3. Build and deploy database project
4. Check in the project to Team Foundation Server (TFS)
5. Manage database changes with SSDT and TFS
6. Seed reference data and other test data for deployment
7. Database Unit test and deployment packaging
3
![Page 4: Managing database project with Visual Studio SSDT and TFS](https://reader033.vdocuments.mx/reader033/viewer/2022052910/559b7e121a28ab04768b45db/html5/thumbnails/4.jpg)
1.1 What is SSDT
• Free download from MSDN
• http://msdn.microsoft.com/en-US/data/tools.aspx
4
![Page 5: Managing database project with Visual Studio SSDT and TFS](https://reader033.vdocuments.mx/reader033/viewer/2022052910/559b7e121a28ab04768b45db/html5/thumbnails/5.jpg)
1.2 Evolving of SSDT
• Visual Studio 2005 DB Pro - Data Dude
• Visual Studio Team System 2008 Database Edition
• Visual Studio 2010 Database Project
-----------------------------------------------------------------
• SSDT
• Visual Studio 2010 SSDT
• Visual Studio 2012 SSDT
Latest news: http://blogs.msdn.com/b/ssdt/
5
![Page 6: Managing database project with Visual Studio SSDT and TFS](https://reader033.vdocuments.mx/reader033/viewer/2022052910/559b7e121a28ab04768b45db/html5/thumbnails/6.jpg)
1.3 Visual Studio 2010 v.s. SSDT 2010
Confusion on Visual Studio 2010 when selecting
project template
•Database Project templates – DB Pro style
• Server Project
• SQL 2005
• SQL 2008
•SSDT Database Project Template
6
![Page 7: Managing database project with Visual Studio SSDT and TFS](https://reader033.vdocuments.mx/reader033/viewer/2022052910/559b7e121a28ab04768b45db/html5/thumbnails/7.jpg)
VS 2010 Database Project Templates
7
![Page 8: Managing database project with Visual Studio SSDT and TFS](https://reader033.vdocuments.mx/reader033/viewer/2022052910/559b7e121a28ab04768b45db/html5/thumbnails/8.jpg)
SSDT Database Project Template
8
![Page 9: Managing database project with Visual Studio SSDT and TFS](https://reader033.vdocuments.mx/reader033/viewer/2022052910/559b7e121a28ab04768b45db/html5/thumbnails/9.jpg)
1.4 Why SSDT
• Manage database objects from Visual Studio – unified interface
• Manage database version with source control tools, e.g. TFS
• Refactoring
• Schema Comparison
• Database Unit Test
9
![Page 10: Managing database project with Visual Studio SSDT and TFS](https://reader033.vdocuments.mx/reader033/viewer/2022052910/559b7e121a28ab04768b45db/html5/thumbnails/10.jpg)
1.5 SSDT Features
• Solution Explorer
• SQL Server Object Explorer – including Project Schema View
• T-SQL Query Window
• Online Connected Development
• Offline Project Development – (localdb)\Projects
• Database Snapshot
• Target switch to different SQL Server versions
• Schema compare between:
• Database
• Database project
• Project snapshot
10
![Page 11: Managing database project with Visual Studio SSDT and TFS](https://reader033.vdocuments.mx/reader033/viewer/2022052910/559b7e121a28ab04768b45db/html5/thumbnails/11.jpg)
1.6 SSDT Limitations
Not feature complete v.s. VS Database Professional (DBPro)
•No data compare (this feature is available now)
•No data generation (this feature is available now)
Third party tool:
•Red Gate Data Compare
•Red Gate Data Generation
11
![Page 12: Managing database project with Visual Studio SSDT and TFS](https://reader033.vdocuments.mx/reader033/viewer/2022052910/559b7e121a28ab04768b45db/html5/thumbnails/12.jpg)
Session agenda
1. Evolution of SSDT
2. Create a database project with Visual Studio / SSDT
3. Build and deploy database project
4. Check in the project to Team Foundation Server (TFS)
5. Manage database changes with SSDT and TFS
6. Seed reference data and other test data for deployment
7. Database Unit test and deployment packaging
12
![Page 13: Managing database project with Visual Studio SSDT and TFS](https://reader033.vdocuments.mx/reader033/viewer/2022052910/559b7e121a28ab04768b45db/html5/thumbnails/13.jpg)
2.1 Create a brand new database project
• Add Member table from Solution Explorer
• Update PK comumn to MemberID
• Set Identity on MemberID
• Add index IX_Member_BirthDate
• Add Meeting table and MeetingAttendee table
• Demo
13
![Page 14: Managing database project with Visual Studio SSDT and TFS](https://reader033.vdocuments.mx/reader033/viewer/2022052910/559b7e121a28ab04768b45db/html5/thumbnails/14.jpg)
2.2 Import existing database into project
1. Design Data Model in PowerDesigner
2. Generate SQL Script from PowerDesigner
3. Run SQL Script to local SQL Instance
4. Import existing database to create the database project
• Demo
14
![Page 15: Managing database project with Visual Studio SSDT and TFS](https://reader033.vdocuments.mx/reader033/viewer/2022052910/559b7e121a28ab04768b45db/html5/thumbnails/15.jpg)
2.3 Create a project snapshot
• Snapshot – point in time project objects
Demo
1
5
![Page 16: Managing database project with Visual Studio SSDT and TFS](https://reader033.vdocuments.mx/reader033/viewer/2022052910/559b7e121a28ab04768b45db/html5/thumbnails/16.jpg)
Session agenda
1. Evolution of SSDT
2. Create a database project with Visual Studio / SSDT
3. Build and deploy database project
4. Check in the project to Team Foundation Server (TFS)
5. Manage database changes with SSDT and TFS
6. Seed reference data and other test data for deployment
7. Database Unit test and deployment packaging
16
![Page 17: Managing database project with Visual Studio SSDT and TFS](https://reader033.vdocuments.mx/reader033/viewer/2022052910/559b7e121a28ab04768b45db/html5/thumbnails/17.jpg)
3.1 Code Analysis
• Add SP: uspShowMeetingAttendee with “select * from”
• Build project
• Project -> Property -> Code Analysis
• Build project
• Update Sp to select FirstName, LastName
• Build project
Demo
17
![Page 18: Managing database project with Visual Studio SSDT and TFS](https://reader033.vdocuments.mx/reader033/viewer/2022052910/559b7e121a28ab04768b45db/html5/thumbnails/18.jpg)
3.2 Publish project
• Publish to Integration
• Publish to Windows Azure SQL Database
Demo
1
8
![Page 19: Managing database project with Visual Studio SSDT and TFS](https://reader033.vdocuments.mx/reader033/viewer/2022052910/559b7e121a28ab04768b45db/html5/thumbnails/19.jpg)
Session agenda
1. Evolution of SSDT
2. Create a database project with Visual Studio / SSDT
3. Build and deploy database project
4. Check in the project to Team Foundation Server (TFS)
5. Manage database changes with SSDT and TFS
6. Seed reference data and other test data for deployment
7. Database Unit test and deployment packaging
19
![Page 20: Managing database project with Visual Studio SSDT and TFS](https://reader033.vdocuments.mx/reader033/viewer/2022052910/559b7e121a28ab04768b45db/html5/thumbnails/20.jpg)
4. Check in the project to Team Foundation Server (TFS)
• Protect database schema objects
• Track schema changes
Demo
• Check in database project
20
![Page 21: Managing database project with Visual Studio SSDT and TFS](https://reader033.vdocuments.mx/reader033/viewer/2022052910/559b7e121a28ab04768b45db/html5/thumbnails/21.jpg)
Session agenda
1. Evolution of SSDT
2. Create a database project with Visual Studio / SSDT
3. Build and deploy database project
4. Check in the project to Team Foundation Server (TFS)
5. Manage database changes with SSDT and TFS
6. Seed reference data and other test data for deployment
7. Database Unit test and deployment packaging
21
![Page 22: Managing database project with Visual Studio SSDT and TFS](https://reader033.vdocuments.mx/reader033/viewer/2022052910/559b7e121a28ab04768b45db/html5/thumbnails/22.jpg)
5.1 Manage Table Change
• Change Member.LastName to varchar
• Checkin change
• Inspect TFS history
22
![Page 23: Managing database project with Visual Studio SSDT and TFS](https://reader033.vdocuments.mx/reader033/viewer/2022052910/559b7e121a28ab04768b45db/html5/thumbnails/23.jpg)
5.2 Refactor
•Update table Member
•Refactor Member.LastName to SurName
•Inspect uspShowMeetingAttendee
Demo
23
![Page 24: Managing database project with Visual Studio SSDT and TFS](https://reader033.vdocuments.mx/reader033/viewer/2022052910/559b7e121a28ab04768b45db/html5/thumbnails/24.jpg)
5.3 Schema Compare
Schema Compare
•Compare Project to live Database
•Update target database
•Compare again
•Schema compare options
2
4
![Page 25: Managing database project with Visual Studio SSDT and TFS](https://reader033.vdocuments.mx/reader033/viewer/2022052910/559b7e121a28ab04768b45db/html5/thumbnails/25.jpg)
Session agenda
1. Evolution of SSDT
2. Create a database project with Visual Studio / SSDT
3. Build and deploy database project
4. Check in the project to Team Foundation Server (TFS)
5. Manage database changes with SSDT and TFS
6. Seed reference data and other test data for deployment
7. Database Unit test and deployment packaging
25
![Page 26: Managing database project with Visual Studio SSDT and TFS](https://reader033.vdocuments.mx/reader033/viewer/2022052910/559b7e121a28ab04768b45db/html5/thumbnails/26.jpg)
6.1 Seed data with SQL Script
• Add sql script to PostDeploymentScript
• SSDT allows script data out
Demo
26
![Page 27: Managing database project with Visual Studio SSDT and TFS](https://reader033.vdocuments.mx/reader033/viewer/2022052910/559b7e121a28ab04768b45db/html5/thumbnails/27.jpg)
6.2 Seed data with BCP
• BCP file in on PostDeploymentScript
2
7
![Page 28: Managing database project with Visual Studio SSDT and TFS](https://reader033.vdocuments.mx/reader033/viewer/2022052910/559b7e121a28ab04768b45db/html5/thumbnails/28.jpg)
6.3 Seed Data with Restore
• Create a separate Seed Database to track seed data
• Backup seed database to network share
• Restore Seed database to target before deployment
• Publish database to update target schema
• Seed data remains
2
8
![Page 29: Managing database project with Visual Studio SSDT and TFS](https://reader033.vdocuments.mx/reader033/viewer/2022052910/559b7e121a28ab04768b45db/html5/thumbnails/29.jpg)
Session agenda
1. Evolution of SSDT
2. Create a database project with Visual Studio / SSDT
3. Build and deploy database project
4. Check in the project to Team Foundation Server (TFS)
5. Manage database changes with SSDT and TFS
6. Seed reference data and other test data for deployment
7. Database Unit test and deployment packaging
29
![Page 30: Managing database project with Visual Studio SSDT and TFS](https://reader033.vdocuments.mx/reader033/viewer/2022052910/559b7e121a28ab04768b45db/html5/thumbnails/30.jpg)
7.1 Database Change Work Flow
1. Code Change
2. Database build – code analysis
3. Database deployment to locadb
4. Data change deployment to localdb
5. Database unit test against localdb
6. Publish database to Testing env
7. Publish database to Production
3
0
![Page 31: Managing database project with Visual Studio SSDT and TFS](https://reader033.vdocuments.mx/reader033/viewer/2022052910/559b7e121a28ab04768b45db/html5/thumbnails/31.jpg)
7.2 Database Unit Test
1. Create a test project
2. Add database test
3. Build test project
4. Switch to Test Explorer
5. Run all tests
6. Exam test results
Demo
3
1
![Page 32: Managing database project with Visual Studio SSDT and TFS](https://reader033.vdocuments.mx/reader033/viewer/2022052910/559b7e121a28ab04768b45db/html5/thumbnails/32.jpg)
7.2 Database Deployment
1. Schema Compare to generate schema change script
2. Data Compare to generate data change script
3. Script 1 + 2 = Deployment package
3
2