How to: Import Updates from a Database into the Database Project

When you first create a database project, you typically import the database schema from an existing production database. If changes were applied to the production server during your development work, you might need to import those changes into your project. You cannot use the Import Database Schema command because it is available only for projects that do not already contain database objects. To import changes that were made to the database server, you must use Schema Compare.

Note

When you use Schema Compare to update a database project, objects that are present in the database project but not in the source database are not dropped. This behavior differs from when you compare two databases. After you update a database project to match a source database, you must manually delete any objects that are not present in the source database from the database project.

To import updates from an existing database into the database project

  1. Open the database project in Visual Studio. For more information, see How to: Open a Database or Server Project.

    Note

    If you do not already have a database project, you should instead see Starting Team Database Development for information about how you can create a database project and import the database objects and settings for the first time.

  2. On the Data menu, point to Schema Compare, and click New Schema Comparison.

    The New Schema Comparison dialog box appears.

    Note

    You can also right-click the database project in Solution Explorer or Schema View, and then click Compare Schema.

  3. In Source Schema, click Database, and click the connection to the database from which you want to import schema updates.

    Note

    You must have permissions to access the source database. For more information, see Required Permissions for Database Features of Visual Studio.

  4. In Target Schema, click Project.

    The project should default to your open database project.

  5. Click OK to begin the comparison.

    When the comparison is completed, the results appear.

  6. Specify the Update Action for the differences.

    By default, all changes are synchronized.

    Note

    If the target of Schema Compare is a project, no dependencies are checked when you change the update action.

  7. On the Data menu, point to Schema Compare, and click Write Updates.

    The specified changes are written to the database project, synchronizing it with the database.

    Note

    You can also click Write Updates on the Schema Compare toolbar.

See Also

Tasks

How to: Create Database and Server Projects

How to: Set Options for Comparing Database Schemas

How to: Compare Database Schemas

Walkthrough: Comparing the Schemas of a Database and Database Project