How to: Create Database and Server Projects

You can manage changes to a database by creating a database project, and you can manage changes to objects and settings on a database server by creating a server project. You can create either of these types of projects by using the New Project Wizard or by performing the equivalent steps manually. You can also create or import the objects and settings that you want to manage, and then check the project and its files in to version control.

To create a database or server project by using the New Project Wizard

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

    The New Project dialog box appears.

  2. Under Installed Templates, expand the Database node, expand the SQL Server node, and click Advanced.

  3. In the list of templates, click the appropriate icon to start the New Project Wizard.

    For example, click SQL Server 2005 Wizard to create a database project for SQL Server 2005.

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

    You can use the same name as that of the database or server that you want to manage, or you can give the project a different name.

  5. In Location, type or click the path of the directory in which you want to create the project.

  6. In Solution, click Create new Solution if you want to create a solution for the project. If you want to add the project to the existing solution, click Add to Solution.

  7. If you want to create a directory to contain the solution, select the Create directory for solution check box.

  8. In Solution Name, type the name that you want to give the solution.

    By default, the solution name matches the project name.

  9. Perform one of the following steps:

    • Make sure that the Add to Source Control check box is selected if you want to add the new solution and project to version control immediately.

    • Clear the Add to Source Control check box if you will add the solution and project to version control later, or if you do not plan to use version control with this solution.

  10. Click OK.

    The New Project Wizard appears.

    Next, you use the wizard to configure your project and specify the database or server from which you want to import objects and settings.

To configure your project and import objects and settings

  1. After you read the Welcome page, click Next.

  2. Specify the type of project that you want to create by performing one of the following steps:

    • Click A database project to manage changes to a user-defined database.

    • Click A server project to manage changes to server objects and the "master" database.

  3. Under SQL Script Files, perform one of the following steps:

    • Click By Schema to organize the files in your project first by schema and then by type of object.

    • Click By Object Type to organize the files in your project by type of object (for example, tables together or views together) as the primary sort criteria.

      Important

      You cannot change the default physical organization after you create the project. You can manually move files within Solution Explorer, but they will be added based on the organization that you specify in the wizard. If you expect to have multiple schemas in your project, you might want to organize your project by schema instead of by object type. Although you cannot change the physical organization of your files, you can change the view of the objects defined in those files. You control the organization within Schema View by right-clicking the project, pointing to Change View, and clicking Object Type or Schema.

  4. Under SQL Script Files, select the Include schema name in the file name check box if you want to include the schema name in the file name. Otherwise, clear the check box.

  5. Click Next.

  6. On the Set Database Options page, configure the options for the database project.

    For more information, see An Overview of the New Database Project Wizard.

    Note

    You can change these options after you create the project. For more information, see How to: Configure Database Properties for Database Projects.

  7. Click Next.

  8. On the Import Database Schema page, perform one of the following steps:

    • If you do not want to import objects or settings, click Next, and go to step 11. You can always import objects and settings into an empty database. For more information, see How to: Import Database Objects and Settings.

    • If you do want to import objects and settings, select the Import existing schema check box.

    Note

    When you import objects and settings, you also import extended properties from the source database. You define extended properties on an object in the file that contains the object definition. For example, you might import extended properties on a table that is named MyTable and, as a result, add sp_addextendedproperty statements to the MyTable.table.sql file. This action affects only sp_addextendedproperty statements.

  9. In Source database connection, click the connection that corresponds to the server and database from which you want to import the objects and settings.

    For a server project, you should specify the "master" database. If the connection does not already exist, click New Connection to create it. If you do not specify a connection, the project is created, but no objects or settings are imported.

    Note

    You can import objects and settings later, if the project does not already contain objects. For more information, see How to: Import Database Objects and Settings and How to: Import Server Objects and Settings.

  10. Configure the import options according to your needs.

    For more information, see An Overview of the New Database Project Wizard.

  11. Click Next.

  12. On the Configure Build/Deploy page, you can specify initial settings to control how the project will be built and deployed.

    For more information, see An Overview of the New Database Project Wizard.

    Note

    You can change these options after you create the project. For more information, see How to: Configure Deployment Settings for Database and Server Projects.

  13. Click Finish to create the project and, if you specified an existing database or server, import objects and settings from it.

    The project is now ready for you to use. You can check it in to version control if you are working in a team environment.

See Also

Tasks

How to: Create Empty Database and Server Projects

Walkthrough: Put an Existing Database Schema Under Version Control

Concepts

Writing and Changing Database Code

An Overview of Database and Server Projects