Home/Journal/Deploying an ASP.NET Core App with MySQL on Fly.io

February 21, 2025

Deploying an ASP.NET Core App with MySQL on Fly.io

A step-by-step guide to redeploying an ASP.NET Core MVC application with MySQL on Fly.io, ensuring a smooth update process.

This is mostly a reference for myself (hi, future me) but hopefully useful for anyone who's already deployed an ASP.NET Core MVC app on Fly.io and just needs to push updates. The Fly.io docs are good, but I always want the shortest possible version.

Here's the workflow.

Install the CLI

If you don't have flyctl yet:

curl -L https://fly.io/install.sh | sh

Authenticate

flyctl auth login

Deploy

Make sure you're in the project directory where fly.toml lives, then:

flyctl deploy

That's usually it. Fly.io handles the containerization and the rest.

Apply database migrations (if needed)

If the schema changed, SSH in and run migrations before the new code starts serving requests:

flyctl ssh console -a <your-app-name>
dotnet ef database update
exit

Restart the app (if needed)

flyctl apps restart <your-app-name>

I've had to do this a couple times when the deploy succeeded but the app didn't pick up the changes right away. A little annoying, but fixable.


Fly.io is pretty nice for this kind of setup, honestly. The first deployment takes some doing, but redeployments are fast once everything's configured.