How to: Create a Database Object
You must follow a two-step process to create a database object when your database is under version control. You must first add the object to your database project, and then you must build and deploy the changes to your database server. You can add a project item for the new database object from Solution Explorer or from Schema View.
For more information about how to build and deploy a new database, see How to: Prepare Database Build Scripts.
For more information about how to build and deploy changes to an existing database, see How to: Deploy Changes to New or Existing Databases.
To create a database object
Open the database project to which you want to add the item. For more information, see How to: Open a Database or Server Project.
In Solution Explorer, click the node under which you want to add the new object. For example, if you want to add a table in a specific schema, expand the Schema Objects node, expand the Schemas node, expand the node for the schema in which you want to add the object, and click the Tables node.
If you click the project, the object will be created at the root level of your project.
On the Project menu, click Add New Item.
The Add New Item dialog box appears.
In Categories, click the group that contains the type of database object that you want to create.
In Templates, click the template for the type of database object that you want to create.
In Name, type the name that you want to give the new database object.
The file that contains the database object is added to the database project in Solution Explorer. The database object is added in the Default Schema specified in the database project properties. When the object definition is valid, the new database object appears in Schema View. In addition, the object definition is opened in the Transact-SQL Editor, which you can use to modify the definition of the object.
The default templates for some objects do not create valid objects until you edit the object definition. For example, when you add a new index, you must modify the object definition to specify the table to which the index applies before the index definition is valid.
After you modify the object definition, open the File menu, and click SaveObjectName.
If the definition is valid, the database object appears in Schema View. You can check your changes in to version control and then build and deploy your changes.