Managing migrations using DbUp
DbUp is an open source library that helps us deploy changes to SQL Server databases. It keeps track of SQL Scripts embedded within an ASP.NET Core project, along with which ones have been executed on the database. It contains methods that we can use to execute the SQL Scripts that haven't been executed yet on the database.
In this section, we are going to add DbUp to our project and configure it to do our database migrations when our app starts up.
Installing DbUp into our project
Let's start by installing DbUp by carrying out the following steps in our backend project, in Visual Studio:
- Go to the Tools menu and then NuGet Package Manager. Then, choose Manage NuGet Packages for Solution....
- On the Browse tab, enter
DbUp
into the search box. - Select the dbup package by Paul Stovell, Jim Burger, Jake Ginnivan, and Damian Maclennan...