Converting .dbp files to .dbproj files
With the release of Visual Studio 2010 Beta 2, database projects with the .dbp extension are deprecated. There are several ways to convert your project manually
- Import Script. Unfortunately this will shred your scripts for schema objects and move any conditional logic into the scriptsignored file.
- Add Existing Item. You could create a Visual Studio 2010 project and use “Add Existing Item” to bring your .dbp scripts into your new project. The downside with this is 1) it is time consuming and 2) you lose the workspace the version control provider needs – therefore loosing history of your files.
- “Include In Project”. Create a new Visual Studio 2010 project and drag your .dbp project folder structure on the top of the .dbproj file. After your finished select “Show All Items” from the Visual Studio 2010 Solution Explorer and then “Include In Project” for your .dbp files. Unless you create the new .dbproj project over the top of your .dbp project you’ll lose version control history.
DbpToDbproj.exe
To help Database Project (.dbp) customers with the upgrade to Visual Studio 2010 I’ve written DbpToDbProj. The source and executable is located here.
This project builds a command-line executable with parameters allowing you to create either a Visual Studio 2010 2005DSP or 2008DSP project, and indicate if the file structure for the ‘Schema Objects’ folder is ‘by schema’ or ‘by type’.
1: c:\Temp>DbpToDbproj.exe /?
2: Database projects that have the file extension .dbp have been deprecated in Visual Studio 2010
3: DbpToDbproj creates a database project with the .dbproj extension to replace the dbp.
4:
5: DbpToDbproj [drive:][path]filename [/target:[2005|2008]] [/DefaultFileStructure:[ByType | BySchema]]
6: [drive:][path]filename
7: Specifies drive, directory and filename for the dbp file to be converted.
8:
9: /target:[2005|2008]
10: Specifies whether the .dbproj to be created is a Sql2005 or a Sql2008 project.
11:
12: /DefaultFileStructure:[ByType | BySchema]]
13: Specifies whether the directory structure of the .dbproj should be by object schema or type.
Specifies whether the directory structure of the .dbproj should be by object schema or type.
As an example, here’s a .dbp project from Visual Studio 2008:
Running DspToDbproj in the same directory as your existing .dbp project will create a file called ‘<dbpfilename>.dbproj’.
1: C:\Temp\dbpProject\dbpProject>DbpToDbproj.exe dbpProject.dbp
2: Converting...
3: C:\Temp\dbpProject\dbpProject\dbpProject.dbp
4: ...to...
5: C:\Temp\dbpProject\dbpProject\dbpProject.dbproj
6: Successfully converted dbp to C:\Temp\dbpProject\dbpProject\dbpProject.dbproj
When the .dbproj file is opened you’ll receive an upgrade prompt. The reason for this is that my command-line utility does not interact with your Version Control system. Instead I place an MSBuild property in the dbproj file called “PostUpgradeAddToSCC”. This property is a flag to the database project system that upgrade has added new files and that these new files should be added to SCC. This only happens after the upgrade process so I had to make the system think an upgrade was necessary. If you don’t use version control you can edit Program.cs and remove the line where I create the “PreviousProjectVersion” MSBuild property. The absence of this property will prevent the upgrade wizard from appearing.
After opening the .dbproj file the following project will appear in the solution. Notice that the script files are maintained as they were in the .dbp project. Each of these script files have a build action of ‘Not In Build’, meaning they do not contribute to the dbproj model. It also creates the standard “Schema Objects”, “Data Generation Plans”, and “Schema Comparisons” folders you’d get with any other Visual Studio 2010 project. If you’re using the new Database Project (.dbproj) project for purely version control you can always delete these directories – otherwise you’ll still be able to import from an existing database or a script.
DspToDbproj will preserve the connections found in the .dbp by writing them into a file called Connections.txt. From these connection strings you should be able to recreate the connection in the Server Explorer manually.
Conclusion
Hopefully this will make the conversion to Visual Studio 2010 a little easier for everyone with .dbp projects. Once again the source and executable is located here. If you have any questions please visit our forums here or ping me through this blog. Thanks!
-- Patrick