Create a Database Project in Visual Studio
Introduction: All software development involves databases. It is very difficult to manage and maintain databases when multiple developers are working on it. Visual studio provides a feature where we can create a database project, where it makes easier to maintain databases.
Below are the steps to create database project in visual studio 2010.
1. Open Visual Studio 2010. Click on File -> New -> Project
2. Select database -> SQL server and choose SQL Server 2008 Database Project.
3. Database project will get created.
4. Now we are ready to compare database project with actual database in SQL server
Click on Data -> Schema Compare -> New Schema Comparison
Source schema is a database/project used to update target database/schema.
5. Schema Comparison can be done using 4 different types.
a. SQL Database to VS database project
Select Source Schema as a Database and Target Schema as a Project.
b. VS database project to SQL database
Select Source Schema as a project and Target Schema as a Database.
c. SQL database to SQL database
Select Source Schema and Target Schema as a Database.
d. VS database project to VS database project
Select Source Schema and Target Schema as a Project.
6. Here is detailed comparison for SQL Database to VS database project
Select database and project and click OK.
Next window will appear.
We will need to use following buttons from toolbar.
7. Click on filter icon and select Non Skip Objects.
8. Click on Refresh Update Script.
9. Then click on Write Updates. Finally click on Refresh icon.
This will update SQL Database to VS database Project.
Conclusion: Visual Studio database project helps developer to manage and maintain database easily. It also makes easier to update databases on the server.
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)