Udostępnij za pośrednictwem


Converting .DBP Projects into Database Projects or Data-tier Application Projects

You cannot use the .dbp database projects with Visual Studio 2010. You must instead use either a database project or a Data-tier Application (DAC) project. You can import the scripts that are contained in your .dbp project into either a database project or a DAC project. After you have imported the scripts, you can build and deploy the new project to your target database.

Choosing a Project Type

Data-tier Application projects support only a subset of the full set of objects that you can create in a SQL Server database. If your database uses features or statements that are not supported by a Data-tier Application project, you should consider using a database project instead. If you want to manage changes to objects that reside in the master database, you should use a server project. For more information about database and server projects, see An Overview of Database and Server Projects. For more information about DAC projects, see Creating and Managing Data-tier Applications and Features Supported in Data-tier Applications on the Microsoft Web site.

Limitations when Importing .DBP Scripts

When you use Import Script to migrate your .dbp project, you might encounter the following issues that will prevent successful migration.

Issue

Notes

Query files (.dtq files) are not imported.

If your .dbp project contained one or more query files (.dtq files), those files are ignored when you import the script.

Database references are not imported.

Database references in .dbp projects are not converted to database references in a .dbproj project. An entry might appear in Solution Explorer, but if you double-click that entry, you navigate to Solution Explorer, instead of operating on the reference. To resolve this after you import, you must remove the incorrect references and manually add the correct database references.

Script files that are not defining the structure of an object might be ignored.

Script files (.sql) that are not defining an object (usually by using CREATE or ALTER statements) are put into the ScriptsIgnoredOnImport file in your solution. Any checks in your scripts that check database state or verify that an object does not already exist will also be put in the ScritpsIgnoredOnImport file.

All scripts in a .dbp file are assumed to be for a single database.

A .dbproj database project is always defines a single database. When your .dbp project is imported, all scripts are assumed to apply to the database that corresponds to the project into which you import. If your .dbp project included scripts for multiple databases, Import Script is not recommended. You might instead consider importing the database definitions from the database instances.

Create a New Project and Import Your Scripts

To convert a .dbp project into a database project or DAC project

  1. On the File menu, point to New, and then click Project.

  2. If you want to convert the .dbp project to a DAC project, go to step 6.

  3. In the New Project dialog box, in the list of Installed Templates, expand the Database node, and then click SQL Server.

    Important

    If you are using Visual Studio Professional, you must expand the SQL Server node and then click Advanced.

  4. In the details pane, click SQL Server 2008 Database Project or SQL Server 2008 Server Project.

    Note

    You could specify a different project type. For more information about the other database project types, see An Overview of Database and Server Projects and How to: Create Database and Server Projects.

  5. Go to step 8.

  6. In the New Project dialog box, in the list of Installed Templates, expand the Database node, and then click SQL Server.

  7. In the details pane, click Data-tier Application.

  8. In Name, type the name that you want to give the new project.

  9. Click OK.

  10. In Solution Explorer, right-click the database project and then click Import Script.

  11. Click Next.

  12. Click Multiple Files.

  13. Click Browse.

  14. Navigate to the parent of the folder that contains the scripts in your .dbp project.

  15. Click the folder that contains your .dbp project scripts.

  16. Click Select Folder.

  17. In the list of files, select the check box for each script that you want to import. Clear the check box for any scripts that you want to skip.

  18. Click Finish.

    The scripts are imported, and a summary appears.

  19. Click Finish.

  20. On the View menu, click Error List.

    The Error List window appears. If the scripts that you imported cause any errors in the database project, those errors appear in the Error List. You can double-click any error to move to the source of that error. If you do not plan to build and deploy your project to a database instance, you can eliminate errors by changing the build action for one or more script files. For more information, see Excluding Script Files.

    Before you can build and deploy your database or server project, you should configure your database properties. For more information, see Configuring Database Projects and Performing a Test Deployment. For more information about how to configure and deploy a Data-tier Application, see Configuring the Server Selection Policy and Deploying Data-tier Application Packages on the Microsoft web site

Excluding Script Files

You can change the build action for one or more script files in your project to exclude them from any build or deploy action that you perform on that project.

To change the build action for a script file

  1. In Solution Explorer, click the script file (.sql) for which you want to change the build action.

  2. Press F4 to open the Properties window.

  3. In the Properties window, change the Build Action to "Not in Build".

    You can repeat this process for each file that you want to exclude when the project is built or deployed.

See Also

Concepts

Starting Team Database Development

Creating and Modify Database and Server Objects

Build and Deploy Databases to an Isolated Development Environment

Analyzing Database Code to Improve Code Quality