I want to find a way to develop database projects quickly in Visual Studio. Any ideas?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I have a method of creating and updating database projects in Visual Studio 2005 that I thought was common knowledge. After asking a few coworkers if they knew how to update their database projects with this method and receiving no’s, I thought I would blog about it and pass along some helpful hints and best practices.
I work a lot with databases and especially stored procedures that are built to be used with business logic/data access .NET framework. I enjoy working with databases and always create database projects to live with my .NET projects. I am psychotic about keeping database projects up to date. I have been burned too many time in my younger years where I needed to create a stored procedure that was deleted or was out of sync with the application using the database.
After creating your database project in Visual Studio 2005 as shown:
alt text http://www.cloudsocket.com/images/image-thumb16.png
Create 3 new directories in the projects: Tables, Stored Procedures and Functions. I usually only stored these for my projects.
alt text http://www.cloudsocket.com/images/image-thumb17.png
I now open the Server Explorer in Visual Studio and create a new connection to my desired database. I am using Northwind as my example. I am not going to walk through the creation of the connection for this example.
alt text http://www.cloudsocket.com/images/image-thumb18.png
I will use a stored procedure as my example on how to update the database project. First I expand the ‘Stored Procedures’ directory in the Server Explorer for the Northwind database. I select a stored procedure.
alt text http://www.cloudsocket.com/images/image-thumb19.png
I drag the stored procedure to the ‘Stored Procedures’ directory in the Solution Explorer and drop it.
alt text http://www.cloudsocket.com/images/image-thumb20.png
alt text http://www.cloudsocket.com/images/image-thumb21.png
If you open the file for the dragged stored procedures you will find that the IDE created the script as followed:
You can now drag over all the tables, functions and remaining stored procedures from your database. You can also right click on each script in the Solution Explorer and run the scripts on your database project’s referenced database.