Easy Schema Migrations in .NET Core

Manfred Lange
The Startup
Published in
17 min readNov 15, 2020

--

Database Schema Maintenance with Fluent Migrator

In this article:

  • Using Fluent Migrator to maintain database schemas
  • Writing and applying database schema migrations
  • A Database class to keep things simple
  • Using up-only migrations to simplify migrations

Introduction

Recap

In a previous article, we created a dev container (see article “Building a Dev Container for .NET Core”). Then we added a second container to run a database server we can use during development (see article “Dockerized SQL Server for Development”). This also served as an example how we can use pre-built container images to make our lives easier as developers.

At this point we have a working development environment but no code. In general, we can use this setup cross-platform, i.e. on Linux, Windows, MacOS, without any change required.

We are ready to introduce the next building block: creating and managing a database schema. This is the main focus of this article. We will use a simple console application to learn how to do this.

Running Example

--

--

Manfred Lange
The Startup

CTO at MacroActive https://www.macroactive.com. I write about improving flow of value in software engineering. LinkedIn https://www.linkedin.com/in/manfredlange