IT:AD:Data:Db:Projects:HowTo:Import Existing Databases
Process
Build a Db Project from a Database
In the last post, I showed how to create a Db project and create SQL tables by hand, or at least start by hand, and finess them via the Schema View.
That’s nice… but most times I don’t start from scripted Databases, and instead whack at databases traditionally, in SQL Server Manager (or now using EF4) and end up needing to import them into the database, where I finesse them as I go along.
So here’s an example of how to do that.
In Visual Studio, we can right click our Db project and simply import an existing Database:
And you get a huge warning here that I want you to remember (notably the ‘master’ part):
But click yes anyway, and then it goes to work…finishing up a little while later with a report:
About now, if you look at the project’s files now you’ll see that the DDL of the tables (as well as other things, such as constraints) has been created:
Build a Database from a Db Project
That’s great. We have the DDL, and yes, in this example, we’ve imported from a db, so we know a db exists…but the whole point of the exercise is to have a DDL script to deploy to a db that doesn’t have a database – or if it has one, update it. So let’s give it a whack…
- See: Project




