Deborah's Developer MindScape






         Tips and Techniques for Web and .NET developers.

July 30, 2013

Creating a Database Project From a Database

Visual Studio 2012 introduced a new database project. This post details how to create one of these new database projects from an existing database.

See this link for an introduction to the SQL Server Database Project.

To create a new database project, you could use Solution Explorer. Right-click on the solution in Solution Explorer, select Add New Project, navigate to the SQL Server project template, and create the project from there.

But if the database already exists, there is an easier way.

To create a SQL Server Database Project from an existing database:

1) Open the SQL Server Object Explorer toolbox using View | SQL Server Object Explorer from Visual Studio.

2) Drill down to the Databases node, then to your database.

3) Right-click and select Create New Project…

image

4) Visual Studio displays the Import Database dialog.

image

5) Enter a project name and select a project location.

image

6) Select any other desired settings and click Start.

7) Visual Studio displays a log of the operations it performs. Click Finish to continue.

image

8) The project then appears in Solution Explorer.

image

Notice that the scripts for all stored procedures, tables, and other SQL Server objects are automatically added to the project.

NOTE: The project *also* appears in SQL Server Object Explorer under the Projects node:

image

But as a developer, you will want to focus on the project in Solution Explorer.

From Solution Explorer you can then add table scripts, stored procedure scripts, data scripts, or any other database scripts.

Use this feature any time you want to "kick-start" your Visual Studio 2012 database project from an existing database.

Enjoy!

1 Comment

  1.   vrunda — July 10, 2014 @ 11:09 pm    Reply

    is there any exe or commands to do the same thing automatically[without UI]?

RSS feed for comments on this post. TrackBack URI

Leave a comment

© 2019 Deborah's Developer MindScape   Provided by WPMU DEV -The WordPress Experts   Hosted by Microsoft MVPs