This article has moved to a new home. For up-to-date documentation please continue reading at http://doc.ready-roll.com/display/RRSQLDOC/Working+with+existing+databases
Importing existing database objects
If you would like to import objects from an existing database, firstly connect the new project to a copy of the database and click Import (Generate Script) within the DBSync tool: a single script to create all of the imported objects will be generated and added to the project.
This operation will also insert a record in the [dbo].[__MigrationLog] table within the source database, marking the migration as deployed. This prevents the script from being re-executed against the target database.
Setting a baseline for an existing database
If you intend to deploy your project to an instance of your database that is different to the one you imported from (eg. you imported from the Dev environment and you now want to deploy to Production), you will need to establish a baseline in your target environment. This can be done within Visual Studio or via command line.
To set a baseline within Visual Studio, firstly connect the project to the target database and open the imported object script for editing. Click Mark as Deployed to prevent the script from being re-executed on the target.
Set a baseline using the Command Prompt/Continuous Integration
When deploying your database project for the first time, specify the BaselineUptoMigrationId property with the filename of the migration script as the value, e.g.
MsBuild.exe AdventureWorks.sqlproj /p:DBDeployOnBuild=True /p:TargetServer=MYDBSERVER /p:BaselineUptoMigrationId=0001_Imported_Objects.sql
As of ReadyRoll 1.3, setting of a baseline for existing databases is mandatory. This avoids the possibility of accidentally deploying over the top of an existing schema (eg. [master] database). If a baseline is not set for an existing database, an error will be raised by the ReadyRoll build engine when creating a patch script.