views:

146

answers:

3

Is there any way to add a SQL Server Database Diagram to source control? I can't seem to find a way to script it out of the database. If so, is there a way to get that diagram into a Visual Studio Database Project for easy deployment?

+1  A: 

to script it to a file try:

http://www.codeproject.com/KB/database/ScriptDiagram2005.aspx

I would not do this.

KM
+0.1 for the lkink, and +0.9 for not doing it (after reading the article ;-)
Treb
+2  A: 

I don't know what the advantage of storing the diagram in source control would be. The database diagrams put an illustration to your database relationships which should be defined elsewhere. So long as you put the creation scripts for your DB in source safe, the diagram should render just fine when you create it and add your tables to it.

RSolberg
You can move entities around in ways that imply grouping on a database diagram which is not explicitly stated in the schema. Yes, the relationships can be generated automatically, but the layout cannot. Have you ever created a new database diagram with all the tables in your database and been satisfied with the layout?
brian
I don't spend that much time with SQL's database diagrams for that very reason. If I needed to give a model to a user or someone else, I would probably consider using Visio or another ER Diagram tool. For me the SQL models are for a quick reference as to what the structures and relationships are. Not something I would view as a permanent item.
RSolberg
A: 

There isn't really an easy way of doing this. I typically do one of a few things for this.

  1. Simply print the document to PDF using something like CutePDF
  2. Use Visio and the Reverse Engineering option to generate the document, then save the visio file
  3. Use Enterprise Architect or similar tool for the process.

I personally use option 3, due to the lifecycle that I take my applications through. But the real thing is what are you looking to store, if it is a static version of the database diagram, any of the above are valid.

Mitchel Sellers