Question

I've added a SQL Server 2008 database project to my Visual Studio 2010 Professional Edition solution in the hope that it might allow me to include my database in version control.

I can commit the schema files for each database object into version control, however these schema files all script objects as create rather than alter, so are not good for colleges getting my changes and updating their databases.

Is this a good way to get my database into source control?

And what would the workflow be for actually using it to update databases to a given revision without losing all the data associated with dropping and re-creating all the tables?

Update: on Premium and Ultimate versions, there is a schema compare tool which makes this easy. This does not exist on Professional. Is there any straightforward manual workaround?

Was it helpful?

Solution

I'm not sure if you can do this in VS 2010 Professional, but in VS 2010 Premium, you can do a schema comparison (Data -> Schema Compare -> New Schema Comparison) between your project and database, and update changes in either direction.

When going from project to database, VS generates a script that copies existing data into a temporary table before dropping the existing one.

OTHER TIPS

The database project has a deploy step (which is present in my Professional copy of VS2010) that will generate a sql script with your sql objects in it.

The key thing here is if you r-click the project, properties, goto deploy and change target database settings to a specific database, when you deploy it will generate a change script for that specific database so it matches the objects in the project (and in theory keep existing data etc).

You can get it to either generate a sql script, or directly update the database. Generating a script is probably a better idea :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top