An Introduction to Toad Extension for Visual Studio Written By Thomas Klughardt Systems Consultant Quest Software, Inc.
Contents Introduction... 2 Installation... 3 Creating Projects... 4 Working with Database Schema... 7 Additional Features... 10 Summary... 12 About the Author... 13 1
Introduction Toad Extension for Visual Studio is an Oracle database schema provider (DSP) for Visual Studio; this plug-in enables developers to manage Oracle database objects inside Visual Studio. This is very appealing because with Visual Studio 2010, Microsoft made a huge effort to support the whole application lifecycle management process. The result is a platform that not only covers the development cycle including work-item tracking, version control, unit testing, and more but also database changes, project planning, quality assurance, and other domains that belong to the lifecycle of an application. By using an offline representation of the database schema, it is possible to keep the schema in sync with the application at all times. Therefore, Toad extends Visual Studio s data tools originally designed for SQL Server by adding support for the Oracle database. 2
Installation Installing Toad Extension for Visual Studio is straightforward. The product s installer detects the installed Visual Studio 2010 program and adds it as a plug-in. Simply click Next through the installation wizard. Figure 1. The Visual Studio installer detects the existing Visual Studio environment 3
Creating Projects Once you ve installed Toad Extension for Visual Studio, you can create your first Oracle project. As with SQL Server projects, your new project is added to a solution. From the right-click menu, select Add à New Project. This opens a wizard that will help you create an Oracle project. Figure 2. Adding an Oracle project to a solution The project is now part of the solution and is managed together with the other components. However, at this point, the project is empty and does not yet contain any database objects; only the containers for object types currently exist. Now we can import the objects from the database into the project, either by connecting to a live database or by extracting the objects from DDL scripts. For this example, we will import an Oracle schema: 4
Figure 3. Importing the schema objects Figure 4. from a database Now that we have the schema DDL represented as source in Visual Studio, we can work with database objects just like any other component of the application. This is particularly advantageous when using Microsoft Team Foundation Server (TFS) to manage source changes or automate deployments. 5
Figure 5. Adding the project components to the version control system It is now much easier to keep the database schema in sync with the application at all times. We can track changes to the database schema as well as the application even through code branches and across labels. In instances where you have to act fast and revert back to a previous version of an application due to a critical problem in production, you would typically have to manually track down and revert all changes to the database schema. This process can lead to subsequent problems (or perhaps even require restoring from a backup). Instead, with Toad Extension for Visual Studio, it is possible to check out a previous version of your database project and quickly generate an ALTER script to reset the database schema structure. 6
Working with Database Schema Another important characteristic of the offline model used in Toad Extension for Visual Studio is that changes are not executed against the live database environment until you chose to deploy them. For instance, this allows you to add a column to a table without impacting other developers or a test environment. When you are done with a new feature or work item, all your changes can be deployed to a live instance in a single batch. Your target schema is, therefore, updated, leaving a living incarnation of your project s source. Figure 6. Representation of a table and the corresponding code view Because you are not making changes in a live database environment, you may think there is no direct feedback from Oracle while working in the offline model. But database changes can lead to inconsistencies, syntax errors, and problem code that may not execute accurately against the database. So Toad constantly checks the syntax and directly reveals errors in Visual Studio s standard error window. These checks are provided for PL/SQL code as well as object DDL code. In fact, because Toad can understand all the dependencies and relationships between objects in your project, changes are validated for semantic accuracy as well all from the safety of an offline project. Figure 7. Syntax errors in DDL scripts and PL/SQL code As already mentioned, inconsistencies can lead to errors upon deployment to a live instance. Therefore, when an object is saved, the whole model is checked. For instance, if you made a change to a referenced column, or if a dependent object becomes invalid, then the corresponding semantic error will be shown. 7
Figure 8. Inconsistent data model When a new version of a database model is deployed, there are several options available to users in Toad Extension for Visual Studio. Of course, with an empty schema, you can generate a complete CREATE script. However, in most cases you will be working with a schema that already contains objects and data. In that case, as a first step, we should compare the schema model on our project to the target database prior to deployment. Figure 9. Comparing project and database This is a useful sanity check, giving you a chance to verify the differences between your project and the database. With the comparison complete, you can see which objects would be modified during deployment. The script that is generated will deploy the incremental changes the delta between the project and the database and identical objects are skipped. 8
Figure 10. Result of a comparison between project and database The changes can be deployed directly to a live database, or you can simply generate an ALTER script. This can be valuable when you intend to give the script to a DBA for manual application with a tool like Toad for Oracle. 9
Additional Features It is helpful to use Toad Extension for Visual Studio to detect possible inconsistencies, but you can go a step beyond mere checks. The product also makes it possible to actively refactor a schema. This means if you make changes to an object, like changing the name, all referencing objects are changed accordingly, so that you have a consistent model after the change. Figure 11. Updating referencing objects for a name change Visual Studio 2010 itself also provides the ability to define unit tests, which can be used to test aspects of your database project code. And with Toad Extension for Visual Studio, this capability is extended to Oracle as well; therefore, you can define and execute unit tests for PL/SQL objects. This allows you to stay inside Visual Studio, minimizing your dependence on other testing frameworks and allowing you to automate your tests via Microsoft Team Foundation Server. Even if you write or maintain very little PL/SQL, Oracle support for these unit tests is very important. 10
Figure 12. Oracle unit test support in Visual Studio 11
Summary Toad Extension for Visual Studio integrates the Oracle database into the Visual Studio development environment. This is valuable because without the Toad extension, you would have to maintain two completely separate development environments one for the application and another for the database. That is costly, time-consuming, and errorprone. At best, merging all your changes into a consistent release is cumbersome. Now, through Toad s integration of the Oracle schema into the Visual Studio environment, the process is no longer manual. Inconsistencies are detected immediately and conflicting changes can be avoided during development before they impact other developers or applications. You can find more information on features and licensing at http://www.toadextensions.com. 12
About the Author Thomas Klughardt is a computer scientist based in Germany with a background in software development and Oracle database technologies. He joined Quest Software in 2007 as a systems consultant, working with Oracle solutions. Thomas is a frequent speaker at the German Oracle User Group (DOAG) and various regional and international events. 13
2011 Quest Software, Inc. ALL RIGHTS RESERVED. This document contains proprietary information protected by copyright. No part of this document may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying and recording for any purpose without the written permission of Quest Software, Inc. ( Quest ). The information in this document is provided in connection with Quest products. No license, express or implied, by estoppel or otherwise, to any intellectual property right is granted by this document or in connection with the sale of Quest products. EXCEPT AS SET FORTH IN QUEST'S TERMS AND CONDITIONS AS SPECIFIED IN THE LICENSE AGREEMENT FOR THIS PRODUCT, QUEST ASSUMES NO LIABILITY WHATSOEVER AND DISCLAIMS ANY EXPRESS, IMPLIED OR STATUTORY WARRANTY RELATING TO ITS PRODUCTS INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL QUEST BE LIABLE FOR ANY DIRECT, INDIRECT, CONSEQUENTIAL, PUNITIVE, SPECIAL OR INCIDENTAL DAMAGES (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF PROFITS, BUSINESS INTERRUPTION OR LOSS OF INFORMATION) ARISING OUT OF THE USE OR INABILITY TO USE THIS DOCUMENT, EVEN IF QUEST HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Quest makes no representations or warranties with respect to the accuracy or completeness of the contents of this document and reserves the right to make changes to specifications and product descriptions at any time without notice. Quest does not make any commitment to update the information contained in this document. If you have any questions regarding your potential use of this material, contact: Quest Software World Headquarters LEGAL Dept 5 Polaris Way Aliso Viejo, CA 92656 www.quest.com email: legal@quest.com Refer to our Web site for regional and international office information. Trademarks Quest, Quest Software, the Quest Software logo, AccessManager, ActiveRoles, Aelita, Akonix, AppAssure, Benchmark Factory, Big Brother, BridgeAccess, BridgeAutoEscalate, BridgeSearch, BridgeTrak, BusinessInsight, ChangeAuditor, ChangeManager, Defender, DeployDirector, Desktop Authority, DirectoryAnalyzer, DirectoryTroubleshooter, DS Analyzer, DS Expert, Foglight, GPOADmin, Help Desk Authority, Imceda, IntelliProfile, InTrust, Invirtus, itoken, I/Watch, JClass, Jint, JProbe, LeccoTech, LiteSpeed, LiveReorg, LogADmin, MessageStats, Monosphere, MultSess, NBSpool, NetBase, NetControl, Npulse, NetPro, PassGo, PerformaSure, Point,Click,Done!, PowerGUI, Quest Central, Quest vtoolkit, Quest vworkspace, ReportADmin, RestoreADmin, ScriptLogic, Security Lifecycle Map, SelfServiceADmin, SharePlex, Sitraka, SmartAlarm, Spotlight, SQL Navigator, SQL Watch, SQLab, Stat, StealthCollect, Storage Horizon, Tag and Follow, Toad, T.O.A.D., Toad World, vautomator, vcontrol, vconverter, vfoglight, voptimizer, vranger, Vintela, Virtual DBA, VizionCore, Vizioncore vautomation Suite, Vizioncore vbackup, Vizioncore vessentials, Vizioncore vmigrator, Vizioncore vreplicator, WebDefender, Webthority, Xaffire, and XRT are trademarks and registered trademarks of Quest Software, Inc in the United States of America and other countries. Other trademarks and registered trademarks used in this guide are property of their respective owners. Updated September, 2011 14
About Quest Software, Inc. Quest Software (Nasdaq: QSFT) simplifies and reduces the cost of managing IT for more than 100,000 customers worldwide. Our innovative solutions make solving the toughest IT management problems easier, enabling customers to save time and money across physical, virtual and cloud environments. For more information about Quest solutions for application management, database management, Windows management, virtualization management and IT management, go to www.quest.com. Contacting Quest Software PHONE 800.306.9329 (United States and Canada) If you are located outside North America, you can find your local office information on our Web site. EMAIL MAIL sales@quest.com Quest Software, Inc. World Headquarters 5 Polaris Way Aliso Viejo, CA 92656 USA Contacting Quest Support Quest Support is available to customers who have a trial version of a Quest product or who have purchased a commercial version and have a valid maintenance contract. Quest Support provides around-the-clock coverage with SupportLink, our Web self-service. Visit SupportLink at https://support.quest.com. SupportLink gives users of Quest Software products the ability to: Search Quest s online Knowledgebase Download the latest releases, documentation and patches for Quest products Log support cases Manage existing support cases View the Global Support Guide for a detailed explanation of support programs, online services, contact information and policies and procedures. TBD-ToadXten4VisualStudio-US-KS 15