In my previous posts, I have covered two forms of database change control. Both of those focused on taking some sort of schema and deploying it. But in this post, I am changing focus to something that stores the deltas and reapplies them. Both DbUp and Code-First Migrations will basically play a continual list of scripts.

With DbUp, you are starting with a list of scripts and applying those to the database. If you have to make a change to the database, you just make another script.

Let’s look at a DbUp example.

Initially, let’s assume we are starting with the following scripts:


If we want to add some order tables to our database, we would just add more scripts:


To use DbUp, you just need to add a console application, do a little configuration, and you are off to the races.

1. Create a console application.

database change control

2. Add NuGet package “DbUp”.

database change control

3. Set up your program.cs to run dbup and have it perform your migrations.

4. Add a migration for TimeLogItems. Add it to a “Scripts” directory.

database change control

5. Write a simple table create script.

6. Make sure you mark the sql script as an embedded resource.

database change control

7. Run it.

The above steps will set up a project for running a database update. DbUp is my personal favorite way to manage database changes. It gives you all the power of full SQL, and it fits the model that I am most used to. Years ago, I worked at a company where we created a database migration system that worked a lot like DbUp. So DbUp feels like home to me.

Share This