gert e.r. drapers group engineering manager microsoft corporation tl45
TRANSCRIPT
Microsoft Visual Studio Team System Database Edition
Gert E.R. DrapersGroup Engineering ManagerMicrosoft Corporation
TL45
Agenda
Declarative Database Development Versioning your Database Schema Incrementally Deploying your Databases Heterogeneous Database Development Extending your Database Development
Environment
CREATE TABLE dbo.Auction( id INT NOT NULL, name VARCHAR(25) NOT NULL, start DATETIME NULL, len INT NULL)
class AuctionApplication( int id; void MethodA();)
The Versioning Challenge
Database
class AuctionApplication( int id; void MethodA(); void MethodB();)
class AuctionApplication( int id; string cacheTitle; void MethodA(); void MethodB();)
Revision History
App
V 1 V 2 V 3
ALTER TABLE dbo.Auction WITH CHECK ADD CONSTRAINT Au_PK PRIMARY KEY (id)
ALTER TABLE dbo.Auction WITH CHECK ADD CONSTRAINT Au_SK UNIQUE (name)
-- version 1 Add table dbo.AuctionIF OBJECT_ID (N'dbo.Auction', N'U') IS NULLBEGINCREATE TABLE dbo.Auction(
id INT NOT NULL, name VARCHAR(25) NOT NULL, start DATETIME NULL, len INT NULL)END
-- version 2 Add PK Au_PKIF NOT EXISTS (SELECT * FROM sys.key_constraints WHERE name ='Au_PK' AND type ='PK')BEGIN
ALTER TABLE Auction WITH CHECK ADD CONSTRAINT Au_PK PRIMARY KEY (id)END
-- version 3 Add UC Au_SKIF NOT EXISTS (SELECT * FROM sys.key_constraints WHERE name ='Au_SK' AND type ='UQ')BEGIN
ALTER TABLE Auction WITH CHECK ADD CONSTRAINT Au_SK UNIQUE (name)END
Manual Versioning
CREATE TABLE dbo.Auction( id INT NOT NULL, name VARCHAR(25) NOT NULL, start DATETIME NULL, len INT NULL)
LogicalDatabase
Versioning when using Declarative Database Developmentclass AuctionApplication
( int id; void MethodA();)
class AuctionApplication( int id; void MethodA(); void MethodB();)
class AuctionApplication( int id; string cacheTitle; void MethodA(); void MethodB();)
Revision History
App
V 1 V 2 V 3
CREATE TABLE dbo.Auction( id INT NOT NULL PRIMARY KEY, name VARCHAR(25) NOT NULL, start DATETIME NULL, len INT NULL)
CREATE TABLE dbo.Auction( id INT NOT NULL PRIMARY KEY, name VARCHAR(25) NOT NULL UNIQUE, start DATETIME NULL, len INT NULL)
Source-controlled and deployed scripts do not need to match!
IncrementalDeployment
LogicalDatabase
Deployment when usingDeclarative Database Development
Revision HistoryV 1 V 2 V 3
NewDeployment
CREATE TABLE dbo.Auction( id INT NOT NULL, name VARCHAR(25) NOT NULL, start DATETIME NULL, len INT NULL)
CREATE TABLE dbo.Auction( id INT NOT NULL PRIMARY KEY, name VARCHAR(25) NOT NULL, start DATETIME NULL, len INT NULL)
CREATE TABLE dbo.Auction( id INT NOT NULL PRIMARY KEY, name VARCHAR(25) NOT NULL UNIQUE, start DATETIME NULL, len INT NULL)
CREATE TABLE dbo.Auction( id INT NOT NULL PRIMARY KEY, name VARCHAR(25) NOT NULL UNIQUE, start DATETIME NULL, len INT NULL)
ALTER TABLE dbo.Auction WITH CHECK ADD CONSTRAINT Au_SK UNIQUE (name)
Declarative Database Development
Specify the shape of the schema objects Not how to create or mutate schema object Expressed in a familiar domain language
Ex. SQL Server SQL DDL statements inside .SQL script files Shape definitions are used to create model
representation of the schema Schema representation:
Can round trip source model source model Programmatic interaction for designers Make model changes Generate artifacts, like incremental deployment scripts
Database Project Functionality
Managing Database Change Versioning of database schemas Incremental deployment of database schemas Schema Comparison Schema Refactoring
Managing Database Schema Quality Column level dependency validation and viewing T-SQL Static Code Analysis (FxCop for SQL) Database Unit Testing / Test Data Generation
Integration in the Application Life Cycle Process, specific work items and roles (MSF) Team Build integration
Visual Studio Team System 2008Database Edition GDR
Builds on top of Visual Studio 2008 SP1 Adds support for SQL Server 2008 Introduces a new product architecture
Database Schema Provider model Separation of Build & Deploy Public Extensibility
Incorporates functionality previouslyshipped in the Power Tools T-SQL Static Code Analysis Dependency Viewer
Many product enhancements and improvements
Model Based All tools work on a single model representation No more DesignDB or need for
local database instance Separation of build and deploy
Build generates single schema artifact .DBSCHEMA file
Deployment Engine Takes .DBSCHEMA file as input Plus configurations files Redistributable .NET components
Architecture Changes
Schema Model
Schema Compilation
SourceDatabase
.dbschemafile
Project System
DDL Scripts(artifacts)
Reverse engineer schemainto DDL artifacts
Compose model representationfrom source code fragments
Build
Interpret,Analyze andValidate
Schema Model
.SQL Source Parse SqlCodeDom Interpret Schema Model
Validate
Building up the Schema Model
All schema objects are represented inside the schema model What is in the model is defined by the provider (DSP)
To load/hydrate a schema model instance Parse SqlCodeDom
Based on parsers Abstract Syntax Tree (AST) Interpretation Schema Model
Symbol list Object References (hard and soft dependencies)
Model Validation Shares rules engine with T-SQL Static Code Analysis
Schema Deployment
Schema Model
TargetDatabase
Schema Model
.dbschemafile
Deployment Engine
Model Diff
Incremental Target UpdateAdditional schema artifacts
.SQL
…
Plan Executors
Build
Build validates the complete model Validates Pre & Post Deployment scripts
Checks syntactical correctness while using SQLCMD variables associated through build configuration
Build serializes the model to .dbschema file Build outputs
Database.sqlcmdvars Database.sqldeployment Database.sqlsettings <ProjectName>.dbschema <ProjectName>.deploymanifest Script.PostDeployment.sql Script.PreDeployment.sql
The Deployment Manifest<Project DefaultTargets="DspDeploy" ToolsVersion="3.5" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <TargetDatabase>AdventureWorks2008</TargetDatabase> <DeployToDatabase>False</DeployToDatabase> <DeployToScript>True</DeployToScript> <OutputPath>.</OutputPath> <DeployScriptFileName>AdventureWorks2008.sql</DeployScriptFileName> <DeploymentConfigurationFile>Database.sqldeployment</DeploymentConfigurationFile> </PropertyGroup> <ItemGroup> <DeploymentExtensionConfiguration Include="Script.PostDeployment.sql"> <__PostdeploymentMetadata> </__PostdeploymentMetadata> </DeploymentExtensionConfiguration> <DeploymentExtensionConfiguration Include="Script.PreDeployment.sql"> <__PredeploymentMetadata> </__PredeploymentMetadata> </DeploymentExtensionConfiguration> <SourceModel Include="AdventureWorks2008.dbschema" /> </ItemGroup> <ItemGroup> <Reference Include="Microsoft.SqlTypes.dbschema"> <LogicalName>{3b4726f4-e981-42d7-9ab0-b500b7508bc9}</LogicalName> </Reference> </ItemGroup> <Import Project="...\Microsoft\VisualStudio\v9.0\TeamData\Microsoft.Data.Schema.SqlTasks.targets" /> <PropertyGroup> <SqlCommandVariablesFile>Database.sqlcmdvars</SqlCommandVariablesFile> </PropertyGroup></Project>
Extensibility Levels
Database Schema Providers SQL Server 2000/2005/2008 Publicly extensible in Visual Studio 2010
Project Feature Extensibility Contextual feature support per provider Publicly extensible in Visual Studio 2010
Feature Extensibility Ability to extend existing tools and features Publicly extensible in Visual Studio 2008 Team
System Database Edition GDR
Database Project Ecosystem
DatabaseRefactoring
DatabaseUnit Testing
Data Generation
T-SQL Static Code
Analysis
Schema Compare
DataCompare
3rd PartyDesigners
3rd PartyTools
SQL Server2008 DSP
ParserScriptDOMInterpreter
Reverse EngineerDeploy
SQL Server2005 DSP
ParserScriptDOMInterpreter
Reverse EngineerDeploy
SQL Server2000 DSP
ParserScriptDOMInterpreter
Reverse EngineerDeploy
3rd PartyDSP
ParserScriptDOMInterpreter
Reverse EngineerDeploy
DSPExtensions
DSPExtensions
DSPExtensions
DSPExtensions
DSPExtensions
DSP Extensions
DSPExtensions
Database Model API
Database Eco Project System
Solution ExplorerSchema View
Dependency ViewerEditor
Project Features
Types of Extensions
Data Generators Value generators for a type instance
Data Distributions Statistical distribution of values
Test Conditions Test assertions to validate database unit tests
T-SQL Static Code Analysis Rules Rule to validate against the schema model
Refactoring Types The refactoring operation like Split Column
Refactoring Targets The source target to which to apply the refactoring operation
Extensions
Have access to The Schema Model
SqlSchemaModel DataSchemaModel Script fragments (source code access) Script DOM representation Token stream representations
All extensions types have abase class and an interface provided
Extension Registration
Extensions are registered through an XML file XML file naming convention
<AssemblyFilename>.Extensions.xml The file extension .Extensions.xml is mandatory The Extensions.xml file has to be placed in the
%ProgramFiles%\Microsoft Visual Studio 9.0\VSTSDB\Extensions directory
Must implement the XML schema defined in %ProgramFiles%\Microsoft Visual Studio 9.0\VSTSDB\
Microsoft.VisualStudio.TeamSystem.Data.Extensions.xsd
<?xml version="1.0" encoding="utf-8"?><extensions assembly="Microsoft.VisualStudio.TeamSystem.Data.Generators, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" version="1" xmlns="urn:Microsoft.VisualStudio.TeamSystem.Data.Extensions" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:Microsoft.VisualStudio.TeamSystem.Data.ExtensionsMicrosoft.VisualStudio.TeamSystem.Data.Extensions.xsd">
<extension type="Microsoft.VisualStudio.TeamSystem.Data.Generators.StringGenerator" enabled="true"/></extensions>
Extending your Database Development Environment Part 1 of 2
Gert E.R. DrapersGroup Engineering ManagerMicrosoft Corp.
demo
Contr.Input
Refactoring Extensibility
RefactoringCommand
RefactoringOperation
RefactoringContributor
.
.
.
Contr.Input
Contr.Input
ContributorRefactoringContributor
ChangeProposal
ChangeProposal
ChangeProposal
Extending your Database Development Environment Part 2 of 2
Gert E.R. DrapersGroup Engineering ManagerMicrosoft Corp.
demo
Database projects provides an extensible declarative database development platform inside Visual Studio Enabling integration of data tier development
in to the application life cycle (ALM) Bringing code focused tooling and solutions
towards the data tier developer Enables the integration and collaboration
between the application and data tier developers
Enabling agile development practices in the data-tier
Summary
Related Content
Blog: http://blogs.msdn.com/gertd
MSDN Forum Visual Studio Team System - Database Professionals http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=725&SiteID=1
Product information: http://msdn.microsoft.com/vsts2008/db
Visual Studio Team System 2008 Database Edition GDR download location:http://www.microsoft.com/downloads/details.aspx?FamilyID=bb3ad767-5f69-4db9-b1c9-8f55759846ed&displaylang=en
Team Developer + Database Edition Merge Informationhttp://msdn.microsoft.com/en-us/vsts2008/products/cc990295.aspx
Related SessionsSession Title Speaker Day Time Location
TL47 Visual Studio Team System: A Lap Around VSTS 2010 Cameron Skinner 10/27 11:00 AM – 12:15PM Room 153
TL52 Team Foundation Server 2010: Cool New Features Brian Harry 10/27 03:30 PM – 04:45 PM Room 151
TL03 Microsoft Visual Studio Team System: Software Diagnostics and Quality for Services
Habib Heydarian; Justin Marks
10/27 03:30 PM – 04:45 PM Room 515A
TL09 Agile Development with Microsoft Visual Studio Lori Lamkin; Sunder Raman
10/27 05:15 PM – 06:30 PM Room 502A
TL45 Microsoft Visual Studio Team System Database Edition: Overview
Gert Drapers 10/27 05:15 PM – 06:30 PM Room 501B
TL59 Visual Studio Debugger Tips & Tricks John Cunningham 10/28 12:45PM – 01:30 PM Room 409A
TL37 Microsoft Visual Studio Team System: Leveraging Virtualization to Improve Code Quality with Team Lab
Ram Cherala 10/29 12:00 PM – 12:45 PM Room 408B
TL61 Panel: The Future of Unit Testing Euan Garden, Jim Newkirk, Peter Provost, Nikolai Tillmann
10/29 12:00 PM – 12:45 PM Room 406A
TL60 Improving Code Quality with Code Analysis Ravs Kaur 10/29 12:00 PM – 12:45 PM Room 409A
TL24 Improving .NET Application Performance and Scalability
Steve Carroll;Ed Glas
10/29 01:15 PM – 02:30 PM Room 153
TL15 Architecture without Big Design Up Front Peter Provost 10/29 04:45 PM – 06:00 PM Room 403
TL04 Microsoft Visual Studio Team System Team Foundation Server: How We Use It at Microsoft
Stephanie Saad 10/30 08:30 AM : 9:45AM Room 151
TL51 Research: Contract Checking and Automated Test Generation with Pex
Mike BarnettNikolai Tillmann
10/30 08:30 AM : 9:45AM Room 403
VSTS 2010 Hands on LabsHOL Code Title
TLHOL07 VSTS 2010: Project Planning, Management, and Design
TLHOL08 VSTS 2010: Architecture Tools
TLHOL09 VSTS 2010: Team Foundation Server
TLHOL10 VSTS 2010: Software Quality
TLHOL11 VSTS 2010: Diagnostics and Performance
Evals & Recordings
Please fill
out your
evaluation for
this session at:
This session will be available as a recording at:
www.microsoftpdc.com
© 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market
conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.