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?
Entity Framework Core 1.1.2
Entity Framework Core Sql Server 1.1.2
.Net Core 1.1
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.
Link to our community library GitHub repo:
Let me know how you go.
I did come by an article with a script that i believe should work. https://www.benday.com/2017/03/17/deploy-entity-framework-core-migrations-from-a-dll/
I’m having an issue discussed here, https://github.com/aspnet/EntityFramework/issues/7889. Once I’ve managed to sort out that then I’ll put through a PR
Sounds great! Looking forward to seeing this!
Thanks for contributing.
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
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?