Azure DevOps, Scrum, & .NET Software Leadership and Consulting Services

Free course! Predicting the Future, Estimating, and Running Your Projects with Flow Metrics

Deploy EF Core Migrations on Linux/MacOS using DLLs


Are you trying to deploy your Entity Framework Core migrations and you’re trying to deploy them WITHOUT having the source code?  Yah.  It’s hard to deploy EF Core migrations using just the DLLs in the published output of your .NET Core project, huh?

If you’re deploying from a Team Foundation Server (TFS) Build or Release or you’re trying to deploy from an Azure DevOps build or release pipeline, you can use my free build/release extension.  For more information about the extension, check out this blog post.

If you’re trying to deploy EF Core migrations from Linux or MacOS, I’ve written a bash script that will handle the details for you.  It takes two parameters.  Parameter 1 is the name of the DLL that contains your EF Core migrations without the ‘.DLL’ extension.  Parameter 2 is the name of the startup DLL for your published .NET Core application without the ‘.DLL’ extension.  

One of the hardest things when trying to deploy EF Core migrations without having the source code is locating a utility DLL named ef.dll.  This is supplied by EF Core and has all the logic for doing the migration deploys.  The location of this file on a server is hard to predict.  This script searches a number of places that ef.dll commonly exists — but it still might not be able to find it.  The *absolute easiest* solution to this ef.dll location problem is to include a copy of ef.dll along with your code and/or my deployment script.  The first place that my script will check for ef.dll is in the directory where the script is run from (aka. $PWD).  So if all else fails, put a copy of ef.dll in that directory.

Here’s a link to download the bash script.  (NOTE: You’ll need to download the script and rename it to end with .sh.)

Enjoy,
-Ben

SUBSCRIBE TO THE BLOG


One response to “Deploy EF Core Migrations on Linux/MacOS using DLLs”

  1. Oliver Avatar
    Oliver

    Hi Ben,

    Would you mind including a licence note in your to script or in the blog post (for example MIT license) to clarify how it may be used?

    Thanks,
    Oliver

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.