How to deploy entity framework core migrations

Hi all,

perhaps my google foo is failing me but I am struggling to find out how I can deploy migrations for entity framework core. With EF 6 we were using the “Run Entity Framework migrations (Update-Database)” community step. There doesn’t appear to be an equivalent for EF Core, so is there an alternative process to use?

Octopus 3.13.2
Entity Framework Core 1.1.2
Entity Framework Core Sql Server 1.1.2
.Net Core 1.1

Hi David,

Thanks for getting in touch! Unfortunately, there is currently nothing built for this that we could find (I asked around). It looks like the only option here will be to script this. However, as always, if you go down the route of scripting this yourself, I can’t help but recommend that you submit a PR to have it made into a community step template. :slight_smile:

Link to our community library GitHub repo:

Let me know how you go. :slight_smile:

Best regards,

Thanks Daniel,

I did come by an article with a script that i believe should work.
I’m having an issue discussed here, Once I’ve managed to sort out that then I’ll put through a PR

Hi David,

Sounds great! Looking forward to seeing this!

Thanks for contributing. :slight_smile:

Best regards,

For the time being I’ve ended up using the DbUp migration method described in this blog post here:

I got the feeling the issue I was having with entity framework core will eventually be resolved by a update from Microsoft.

The only difference I had from the post was the method of adding the step. In Octopus 3.13.2 I added the “Deploy a Package step”

This method means a little more work as you have to create a new project to implement it. I’ll keep an eye on it and if its fixed or I find a solution I’ll create that community step.

I had to make few modifications to the script in order to set the dll paths right.
Here is how it is looking now

set EfMigrationsNamespace=%Dummy.WebAPI
set EfMigrationsDllName=%Dummy.WebAPI.deps.dll
set EfMigrationsDllDepsJson=%Dummy.WebAPI.deps.json
set EfMigrationsStartupAssembly=%Dummy.Data.dll
set DllDir=%cd%
set PathToNuGetPackages=%USERPROFILE%.nuget\packages
set PathToEfDll=%PathToNuGetPackages%\\1.1.1\tools\netcoreapp1.0\ef.dll
ECHO %PathToEfDll%

dotnet exec --depsfile .%EfMigrationsDllDepsJson% --additionalprobingpath %PathToNuGetPackages% %PathToEfDll% database update --assembly .%EfMigrationsDllName% --startup-assembly .%EfMigrationsStartupAssembly% --project-dir . --content-root %DllDir% --data-dir %DllDir% --verbose --root-namespace %EfMigrationsNamespace%

However the script throws index oput of bound error which is very confusing to me. Here is the exception.

System.IndexOutOfRangeException: Index was outside the bounds of the array.
at Microsoft.DotNet.Cli.CommandLine.CommandLineApplication.ParseOption(Boolean isLongOption, CommandLineApplication c
ommand, String[] args, Int32& index, CommandOption& option)
at Microsoft.DotNet.Cli.CommandLine.CommandLineApplication.Execute(String[] args)
at Microsoft.EntityFrameworkCore.Tools.Program.Main(String[] args)
Index was outside the bounds of the array.

Any clue to this error?