Now it’s time for some real meat and potatoes: the Upgrade service! DAC upgrades are done in-place on an existing database. To get started you must have:

  1. A database you want to upgrade (must be registered already)
  2. A DACPAC you want upgrade with


At a high level, the upgrade interface assumes the following intent: you want to make the target database look exactly like the schema defined in the DACPAC. Remember that a DACPAC contains only schema definition, so how does it go about actually upgrading a database?


Step one; DACFx loads the schema definition from the DACPAC into an in-memory schema model we’ll creatively refer to as SchemaModelV2 because it’s the newer version of the schema. Step two; DACFx uses the Extract service to create a second in-memory schema model from the database you want to upgrade. We’ll refer to the current database schema model as SchemaModelV1 because it’s the current schema model.


DACFx now has 2 models, so the next step is to compare the models in order to determine what the differences are. An example difference might be that V1 has a table T1 with 2 columns whereas V2 has a table T1 with the same two columns plus a third one in which case the difference between the two models would be a new column for table T1. Once all the columns are identified, DACFx creates a T-SQL script which when applied to the target database, will ensure that its schema is no longer different than the V2 schema from the DACPAC.


The scripts created by DACFx are sensitive to dependencies and ordering and will generally do their best to ensure the most efficient script is produced. Let’s take a look at a DACFx upgrade in action:


Once the upgrade has completed successfully, the registration for the database is updated to reflect the new version number and description from the DACPAC you just upgraded with. To summarize what happens during an upgrade:

  1. Validation (covered in the previous post)
  2. Compare DACPAC to database
  3. Script differences
  4. Apply script to database
  5. Update registration


So that’s the simple upgrade story. The next post covers some more complex upgrade topics.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: