dat433 under the hood of visual studio team edition for database professionals

33

Upload: dylan-terry

Post on 17-Dec-2015

227 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: DAT433 Under the Hood of Visual Studio Team Edition for Database Professionals
Page 2: DAT433 Under the Hood of Visual Studio Team Edition for Database Professionals

DAT433DAT433

Under the Hood ofUnder the Hood ofVisual Studio Team EditionVisual Studio Team Editionfor Database Professionalsfor Database Professionals

Page 3: DAT433 Under the Hood of Visual Studio Team Edition for Database Professionals

DAT433DAT433 Under the Hood ofUnder the Hood ofVisual Studio Team EditionVisual Studio Team Editionfor Database Professionalsfor Database Professionals

DAT433DAT433 Under the Hood ofUnder the Hood ofVisual Studio Team EditionVisual Studio Team Editionfor Database Professionalsfor Database Professionals

Gert E.R. DrapersGert E.R. DrapersArchitect/Development ManagerArchitect/Development ManagerMicrosoft CorporationMicrosoft Corporation

Page 4: DAT433 Under the Hood of Visual Studio Team Edition for Database Professionals

AgendaAgenda

The Project SystemThe Project SystemUnderstanding the SchemaUnderstanding the Schema

The Schema Object ContainerThe Schema Object Container

Build and DeployBuild and Deploy

Data GenerationData GenerationGenerator ExtensibilityGenerator Extensibility

Distributor ExtensibilityDistributor Extensibility

Generating from the Command LineGenerating from the Command Line

Database Unit TestingDatabase Unit TestingUsing the Code UnderneathUsing the Code Underneath

Data Driven Testing Data Driven Testing

Page 5: DAT433 Under the Hood of Visual Studio Team Edition for Database Professionals

DatabaseDatabaseProjectProject

(*) Not implemented in the current CTP(*) Not implemented in the current CTP

Import database schemaImport database schema

Reverse engineer existing .SQL script files (*)Reverse engineer existing .SQL script files (*)

Create New ProjectCreate New Project

SQLSQLScriptScript

DatabasDatabasee

ProjectProjectTemplatTemplat

ee

SQLSQLServerServer

DatabasDatabasee

Collection Collection of .SQL file of .SQL file containing containing T-SQL DDL T-SQL DDL fragmentsfragments

Project ModelProject ModelThe center of gravityThe center of gravity

Page 6: DAT433 Under the Hood of Visual Studio Team Edition for Database Professionals

Offline ModelOffline Model

Project modelProject modelSchema Objects representationSchema Objects representation

Collection of T-SQL DDL fragmentsCollection of T-SQL DDL fragments

Objects are Parsed and Interpreted at:Objects are Parsed and Interpreted at:Project Load TimeProject Load Time

Object Change (save)Object Change (save)

Source Control Sync (external change)Source Control Sync (external change)

Page 7: DAT433 Under the Hood of Visual Studio Team Edition for Database Professionals

Loading, importing or reverse engineering shreds Loading, importing or reverse engineering shreds the schema definition into the smallest possible the schema definition into the smallest possible DDL fragments, for example:DDL fragments, for example:TableTable

CREATE TABLE [dbo].[Territories]CREATE TABLE [dbo].[Territories]((

[TerritoryID] [nvarchar] (20) NOT NULL,[TerritoryID] [nvarchar] (20) NOT NULL,[TerritoryDescription] [nchar] (50) NOT NULL,[TerritoryDescription] [nchar] (50) NOT NULL,[RegionID] [int] NOT NULL[RegionID] [int] NOT NULL

) ON [PRIMARY]) ON [PRIMARY]

Primary KeyPrimary KeyALTER TABLE [dbo].[Territories] ADD CONSTRAINT ALTER TABLE [dbo].[Territories] ADD CONSTRAINT [PK_Territories] PRIMARY KEY NONCLUSTERED [PK_Territories] PRIMARY KEY NONCLUSTERED ([TerritoryID]) ON [PRIMARY]([TerritoryID]) ON [PRIMARY]

FKFKALTER TABLE [dbo].[Territories] ADDALTER TABLE [dbo].[Territories] ADDCONSTRAINT [FK_Territories_Region] FOREIGN KEY CONSTRAINT [FK_Territories_Region] FOREIGN KEY ([RegionID]) REFERENCES [dbo].[Region] ([RegionID])([RegionID]) REFERENCES [dbo].[Region] ([RegionID])

Shredding in to SQL FragmentsShredding in to SQL Fragments

Page 8: DAT433 Under the Hood of Visual Studio Team Edition for Database Professionals

Understanding Your SchemaUnderstanding Your Schema

Build-up understanding of the DDL Fragments in StagesBuild-up understanding of the DDL Fragments in StagesPhase-1 ParsingPhase-1 Parsing

Retrieve the object identifier and object typeRetrieve the object identifier and object type

Phase-1 InterpretationPhase-1 InterpretationRetrieve additional type specifics like schemabindingRetrieve additional type specifics like schemabinding

Phase-1 SQL Server Compile ValidationPhase-1 SQL Server Compile ValidationPerform compile time validation against (local) SQL Server, design Perform compile time validation against (local) SQL Server, design database with is associated with the projectdatabase with is associated with the project

Phase-2 ParsingPhase-2 ParsingBuild a full AST (Abstract Syntax Tree, aka the parse tree) for the Build a full AST (Abstract Syntax Tree, aka the parse tree) for the DDL fragmentDDL fragment

Phase-2 InterpretationPhase-2 InterpretationRetrieve the remaining type specific detail from the ASTRetrieve the remaining type specific detail from the AST

All stages contribute to building and maintaining the All stages contribute to building and maintaining the schema contextschema context

Object symbol listObject symbol list

Object dependency graph (tracking)Object dependency graph (tracking)

Page 9: DAT433 Under the Hood of Visual Studio Team Edition for Database Professionals

P1 P1 ParsingParsing

P1 P1 InterpreInterpre-tation-tation

SchemaSchemaManageManage

rrDesignDesign

DBDB

P2 P2 ParsingParsing

P2 P2 InterpreInterpre-tation-tation

SchemaSchemaManageManage

rr

ErrorErrorListList

WarninWarningg

ListList

FailedFailedFailedFailed FailedFailed

FailedFailed FailedFailed FailedFailed

SuccessSuccess

SuccessSuccess SuccessSuccess

SuccessSuccess

Su

cces

Su

cces

ss

UpdateUpdateSchemaSchemaContextContext

Add toAdd toSchemaSchemaContextContext

Succes

Successs

Understanding Schema ObjectsUnderstanding Schema Objects

Page 10: DAT433 Under the Hood of Visual Studio Team Edition for Database Professionals

File Naming & Extension File Naming & Extension SchemeScheme

Everything is a .SQL fileEverything is a .SQL fileAssociated with the T-SQL editorAssociated with the T-SQL editor

Using a two part naming scheme to Using a two part naming scheme to identify typesidentify types

This is not required, but helps identification of This is not required, but helps identification of typestypes

By default the file name encodes the By default the file name encodes the object nameobject name

Not requiredNot requiredFilename do not have to match the containing type Filename do not have to match the containing type namename

Required since SQL Server namespace restrictions do Required since SQL Server namespace restrictions do not match the file system naming restrictionsnot match the file system naming restrictions

Page 11: DAT433 Under the Hood of Visual Studio Team Edition for Database Professionals

Data Generation PlansData Generation PlansSchema ObjectsSchema Objects

FunctionsFunctionsStored ProceduresStored ProceduresTablesTablesViewsViewsSecuritySecurity

RolesRolesUsersUsersRolesRoles

Application RolesApplication RolesDatabase RolesDatabase Roles

StorageStorageFile GroupsFile GroupsFull Text CatalogsFull Text Catalogs

TypesTypesUser-defined Data TypesUser-defined Data Types

ScriptsScriptsPost-DeploymentPost-DeploymentPre-DeploymentPre-Deployment

Directory Structure SQL 2000 Directory Structure SQL 2000 ProjectProject

Page 12: DAT433 Under the Hood of Visual Studio Team Edition for Database Professionals

Directory Structure SQL 2005 Directory Structure SQL 2005 ProjectProject

Data Generation PlansData Generation PlansSchema ObjectsSchema Objects

AggregatesAggregatesAssembliesAssembliesDatabase TriggersDatabase TriggersFunctionsFunctionsSecuritySecurity

Asymmetric KeysAsymmetric KeysCertificatesCertificatesEndpointsEndpointsRolesRoles

Application RolesApplication RolesDatabase RolesDatabase Roles

SchemasSchemasSymmetric KeysSymmetric KeysUsersUsers

Service BrokerService BrokerContractsContractsEvent NotificationsEvent NotificationsMessage TypesMessage TypesQueuesQueuesRemote Service BindingRemote Service BindingRoutesRoutesServicesServices

Schema Objects…Schema Objects…StorageStorage

File GroupsFile Groups

Full Text CatalogsFull Text Catalogs

Partition FunctionsPartition Functions

Partition SchemesPartition Schemes

Stored ProceduresStored Procedures

SynonymsSynonyms

TablesTables

TypesTypesUser-defined Data TypesUser-defined Data Types

User-defined Types (CLR)User-defined Types (CLR)

XML Schema CollectionsXML Schema Collections

ViewsViews

ScriptsScriptsPost-DeploymentPost-Deployment

Pre-DeploymentPre-Deployment

Page 13: DAT433 Under the Hood of Visual Studio Team Edition for Database Professionals

Exploring the File StructureExploring the File Structure

Page 14: DAT433 Under the Hood of Visual Studio Team Edition for Database Professionals

DatabaseDatabaseProjectProject

(*) Not implemented in the current CTP(*) Not implemented in the current CTP

Import database schemaImport database schema

Reverse engineer existing .SQL script files (*)Reverse engineer existing .SQL script files (*)

Create New ProjectCreate New Project

SQLSQLScriptScript

DatabasDatabasee

ProjectProjectTemplatTemplat

ee

SQLSQLServerServer

DatabasDatabasee

DeployDeploySQLSQL

ScriptScript

SQLSQLServerServer

DatabasDatabasee

Build projectBuild project

Deploy projectDeploy project

Build & DeployBuild & Deploy

Page 15: DAT433 Under the Hood of Visual Studio Team Edition for Database Professionals

Command Line BuildingCommand Line Building

Using devenv.exeUsing devenv.exeVisual Studio shell in command line modeVisual Studio shell in command line mode

Using MSBuild.exeUsing MSBuild.exeImportant note:Important note:

In CTP3 the project needs to be opened inside Visual In CTP3 the project needs to be opened inside Visual Studio!Studio!

Page 16: DAT433 Under the Hood of Visual Studio Team Edition for Database Professionals

Project PropertiesProject Properties

SET optionsSET optionsOnly override when differentOnly override when different

CollationsCollationsOnly override when differentOnly override when different

Difference between New and UpdateDifference between New and Update

Page 17: DAT433 Under the Hood of Visual Studio Team Edition for Database Professionals

Build – New database scriptBuild – New database scriptmsbuild NorthwindOnline.dbproj /t:buildmsbuild NorthwindOnline.dbproj /t:build

msbuild NorthwindOnline.dbproj /t:build msbuild NorthwindOnline.dbproj /t:build /p:Configuration="New Deployment"/p:Configuration="New Deployment"

Build – Update for defined target serverBuild – Update for defined target servermsbuild NorthwindOnline.dbproj /t:build msbuild NorthwindOnline.dbproj /t:build /p:Configuration="Update Deployment" /p:Configuration="Update Deployment" /p:TargetConnectionString="Data Source=(local)\/p:TargetConnectionString="Data Source=(local)\sql80;Integrated Security=True;Pooling=False;" sql80;Integrated Security=True;Pooling=False;" /p:TargetDatabase="NorthwindOnlineTestRun"/p:TargetDatabase="NorthwindOnlineTestRun"

Building Using MSBuildBuilding Using MSBuild

Page 18: DAT433 Under the Hood of Visual Studio Team Edition for Database Professionals

Deploying Using MSBuildDeploying Using MSBuild

Deploy – New databaseDeploy – New databasemsbuild NorthwindOnline.dbproj /t:deploy msbuild NorthwindOnline.dbproj /t:deploy /p:Configuration="New Deployment"/p:Configuration="New Deployment"

Deploy – Update DatabaseDeploy – Update Databasemsbuild NorthwindOnline.dbproj /t:deploy msbuild NorthwindOnline.dbproj /t:deploy /p:Configuration="Update Deployment" /p:Configuration="Update Deployment" /p:TargetConnectionString="Data Source=(local)\/p:TargetConnectionString="Data Source=(local)\sql80;Integrated Security=True;Pooling=False;"sql80;Integrated Security=True;Pooling=False;"

Page 19: DAT433 Under the Hood of Visual Studio Team Edition for Database Professionals

Misc. Actions Using MSBuildMisc. Actions Using MSBuild

All (Build + Deploy)All (Build + Deploy)msbuild NorthwindOnline.dbproj /t:allmsbuild NorthwindOnline.dbproj /t:all

CleanCleanmsbuild NorthwindOnline.dbproj /t:cleanmsbuild NorthwindOnline.dbproj /t:clean

msbuild NorthwindOnline.dbproj /t:clean msbuild NorthwindOnline.dbproj /t:clean /p:Configuration="New Deployment"/p:Configuration="New Deployment"

msbuild NorthwindOnline.dbproj /t:clean msbuild NorthwindOnline.dbproj /t:clean /p:Configuration="Update Deployment"/p:Configuration="Update Deployment"

Page 20: DAT433 Under the Hood of Visual Studio Team Edition for Database Professionals

MSBuild Task: MSBuild Task: SqlBuild/SqlDeploySqlBuild/SqlDeploy

BuildType { "New Deployment" | "Update Deployment“ }BuildType { "New Deployment" | "Update Deployment“ }TargetConnectionStringTargetConnectionStringTargetDatabaseTargetDatabaseBuild options:Build options:

DefaultCollation {"True" | "False“}DefaultCollation {"True" | "False“}EnableFullTextIndexing {"True" | "False“}EnableFullTextIndexing {"True" | "False“}ScriptCreateDBStatement {"True" | "False“}ScriptCreateDBStatement {"True" | "False“}GenerateDropsIfNotInProject {"True" | "False“}GenerateDropsIfNotInProject {"True" | "False“}SourceDatabase {"True" | "False“}SourceDatabase {"True" | "False“}

Set options:Set options:ARITHABORT {"True" | "False“}ARITHABORT {"True" | "False“}NUMERIC_ROUNDABORT {"True" | "False“}NUMERIC_ROUNDABORT {"True" | "False“}ANSI_NULLS {"True" | "False“}ANSI_NULLS {"True" | "False“}CONCAT_NULL_YIELDS_NULL {"True" | "False“}CONCAT_NULL_YIELDS_NULL {"True" | "False“}ANSI_PADDING {"True" | "False“}ANSI_PADDING {"True" | "False“}ANSI_WARNINGS {"True" | "False“}ANSI_WARNINGS {"True" | "False“}QUOTED_IDENTIFIER {"True" | "False“}QUOTED_IDENTIFIER {"True" | "False“}

Page 21: DAT433 Under the Hood of Visual Studio Team Edition for Database Professionals

Command Line Build & DeployCommand Line Build & Deploy

Page 22: DAT433 Under the Hood of Visual Studio Team Edition for Database Professionals

Provisioning Multiple ServersProvisioning Multiple Servers

How can I deploy to multiple targets?How can I deploy to multiple targets?

The Database Project only understand a The Database Project only understand a single target server/database at the timesingle target server/database at the time

You can use the MSBuild tasks to provision You can use the MSBuild tasks to provision multiple serversmultiple servers

Using command line or tool that calls the Using command line or tool that calls the MSBuild infrastructureMSBuild infrastructure

Pseudo codePseudo codefor each server+database combination in listfor each server+database combination in list{{

SqlBuildTask SqlBuildTask SqlDeployTask SqlDeployTask

}}

Page 23: DAT433 Under the Hood of Visual Studio Team Edition for Database Professionals

Data Generator ExtensibilityData Generator Extensibility

GeneratorsGeneratorsImplement:Implement:

IDesignerIDesigner

IGeneratorIGenerator

Base classBase classGeneratorGenerator

AttributesAttributesGeneratorAttributeGeneratorAttribute

GeneratorNameAttributeGeneratorNameAttribute

DistributionsDistributionsImplement:Implement:

IDistributionIDistribution

RegistrationRegistration

Page 24: DAT433 Under the Hood of Visual Studio Team Edition for Database Professionals

Generators and Distributions have to:Generators and Distributions have to:Live in or under the: %ProgramFiles%\Microsoft Visual Live in or under the: %ProgramFiles%\Microsoft Visual Studio 8\DBPro\Extensions directoryStudio 8\DBPro\Extensions directory

Get registered in the %ProgramFiles%\Microsoft Visual Get registered in the %ProgramFiles%\Microsoft Visual Studio 8\DBPro\Studio 8\DBPro\Microsoft.VisualStudio.TeamSystem.Data.Extensions.xml Microsoft.VisualStudio.TeamSystem.Data.Extensions.xml filefile

Be strong key signedBe strong key signed<?xml version="1.0" encoding="us-ascii"?><?xml version="1.0" encoding="us-ascii"?><types version="1"><types version="1">

<type>Microsoft.VisualStudio.TeamSystem.Data.Generators.RegexString, <type>Microsoft.VisualStudio.TeamSystem.Data.Generators.RegexString, Microsoft.VisualStudio.TeamSystem.Data.Generators, Microsoft.VisualStudio.TeamSystem.Data.Generators, Version=2.0.0.0, Version=2.0.0.0, Culture=neutral, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3aPublicKeyToken=b03f5f7f11d50a3a

</type></type><type>Microsoft.VisualStudio.TeamSystem.Data.Generators.Exponential,<type>Microsoft.VisualStudio.TeamSystem.Data.Generators.Exponential,

Microsoft.VisualStudio.TeamSystem.Data.Generators, Microsoft.VisualStudio.TeamSystem.Data.Generators, Version=2.0.0.0, Version=2.0.0.0, Culture=neutral, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3aPublicKeyToken=b03f5f7f11d50a3a

</type></type></types></types>

RegistrationRegistration

Page 25: DAT433 Under the Hood of Visual Studio Team Edition for Database Professionals

Extending the Data GenerationExtending the Data Generation

Page 26: DAT433 Under the Hood of Visual Studio Team Edition for Database Professionals

Database Unit TestingDatabase Unit Testing

Database Unit Test DesignerDatabase Unit Test DesignerSimilar to WinForms DesignerSimilar to WinForms Designer

Provides T-SQL View of Database Unit TestProvides T-SQL View of Database Unit Test

Round-trips C# / VB Team Test Unit Test CodeRound-trips C# / VB Team Test Unit Test Code

Generates C# or VB.NET CodeGenerates C# or VB.NET CodeStandard Team Test classes &methodsStandard Team Test classes &methods

Standard ADO.NET Data Access CodeStandard ADO.NET Data Access Code

Page 27: DAT433 Under the Hood of Visual Studio Team Edition for Database Professionals

Extending Database Unit TestsExtending Database Unit TestsCustomizing generated codeCustomizing generated code

Custom Verification LogicCustom Verification LogicGo beyond supplied test conditions with custom Go beyond supplied test conditions with custom C#\VB verification logicC#\VB verification logic

Managing TransactionsManaging TransactionsCapability of putting tests in automatic rollback Capability of putting tests in automatic rollback mode to always maintain original state of mode to always maintain original state of databasedatabase

Data Driven TestingData Driven TestingDrive database test with parameters supplied Drive database test with parameters supplied from specified data sourcefrom specified data source

Page 28: DAT433 Under the Hood of Visual Studio Team Edition for Database Professionals

Sachin RekhiSachin RekhiProgram ManagerProgram ManagerVisual Studio Team SystemVisual Studio Team System

Extending Database Unit TestsExtending Database Unit Tests

Page 29: DAT433 Under the Hood of Visual Studio Team Edition for Database Professionals

ResourcesResources

Chalk TalksChalk TalksVisual Studio Team Edition for Database Visual Studio Team Edition for Database Professionals: Overview Professionals: Overview

DEV TLC Theatre 6/15/2006 9:45AM-11:00AMDEV TLC Theatre 6/15/2006 9:45AM-11:00AM

Hands on LabsHands on LabsDEV008 Take a Tour of Visual Studio 2005 DEV008 Take a Tour of Visual Studio 2005 Team System for Database ProfessionalsTeam System for Database Professionals

Page 30: DAT433 Under the Hood of Visual Studio Team Edition for Database Professionals

Resources…Resources…

CTP 3 Download SiteCTP 3 Download Sitehttp://download.microsoft.com/download/1/a/3/1a32ea84http://download.microsoft.com/download/1/a/3/1a32ea84-11a3-4adf-953e-7a65b9831f5a/VSDATAD1.img-11a3-4adf-953e-7a65b9831f5a/VSDATAD1.img

Team WebsiteTeam Websitehttp://msdn.microsoft.com/vstudio/teamsystem/products/http://msdn.microsoft.com/vstudio/teamsystem/products/dbpro/default.aspxdbpro/default.aspx

Product ForumProduct Forumhttp://forums.microsoft.com/MSDN/ShowForum.aspx?Forhttp://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=725&SiteID=1umID=725&SiteID=1

PowerToys and SamplesPowerToys and Sampleshttp://gotdotnet.com/Workspaces/Workspace.aspx?id=37http://gotdotnet.com/Workspaces/Workspace.aspx?id=378460fd-1254-427b-aa7d-e777a826a5648460fd-1254-427b-aa7d-e777a826a564

BlogsBlogshttp://http://blogs.msdn.com/gertdblogs.msdn.com/gertd

Page 31: DAT433 Under the Hood of Visual Studio Team Edition for Database Professionals

SummarySummary

Understanding the schema references and Understanding the schema references and relationshipsrelationships

Using .SQL files as canonical Using .SQL files as canonical representationrepresentation

Command Line Access through MSBuild Command Line Access through MSBuild taskstasks

Extensibility of Data Generation Extensibility of Data Generation

Customization of the Database Unit TestingCustomization of the Database Unit Testing

Page 32: DAT433 Under the Hood of Visual Studio Team Edition for Database Professionals

Fill out a session Fill out a session evaluation on evaluation on CommNet for CommNet for

a chance toa chance toWin an XBOX Win an XBOX

360!360!

Page 33: DAT433 Under the Hood of Visual Studio Team Edition for Database Professionals

© 2006 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.