Skip to content

EF Core 2 Migrations in VSTS CD Release #9841

Closed as not planned
Closed as not planned

Description

@footedr

Attempting to execute the following batch script that runs an EF Core 2 migration against published code in a VSTS continuous delivery release (adapted from Ben Day's article located here: https://www.benday.com/2017/03/17/deploy-entity-framework-core-migrations-from-a-dll/).

`set EfMigrationsNamespace=%1
set EfMigrationsDllName=%2.dll
set EfMigrationsDllDepsJson=%2.deps.json
set DllDir=%cd%
set PathToNuGetPackages=%USERPROFILE%.nuget\packages
set NuGetFallbackFolder="C:\Program Files\dotnet\sdk\NuGetFallbackFolder"
set PathToEfDll="C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.entityframeworkcore.tools.dotnet\2.0.0\tools\netcoreapp2.0\ef.dll"

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

This works locally, but fails in the hosted agent because it cannot find the location of %PathtoEfDll%. Where can I reliably locate the ef.dll on the hosted vs2017 build agent?

Activity

  1. ajcvickers commented on Sep 18, 2017

    @ajcvickers
    Contributor

    @footedr Are you saying that ef.dll is not present on the disk after installation of the .NET 2.0 SDK? Have you checked whether it is under Program Files or Program Files (x86)?

  2. footedr commented on Sep 19, 2017

    @footedr
    Author

    Are you saying that ef.dll is not present on the disk after installation of the .NET 2.0 SDK? Have you checked whether it is under Program Files or Program Files (x86)?

    Correct. I tried both Program Files and Program Files (x86).

  3. added this to the 2.1.0 milestone on Sep 20, 2017
  4. broersa commented on Oct 6, 2017

    @broersa

    I managed to find the ef.dll and copy it in my artifacts. But when I run it in a Release I get the following error: A fatal error was encountered. The library 'libhostpolicy.so' required to execute the application was not found in...
    Anyone?

  5. bricelam commented on Oct 9, 2017

    @bricelam
    Contributor

    You may also need to copy ef.runtimeconfig.json...

  6. yzorg commented on Dec 7, 2017

    @yzorg

    Just a comment / question: I have a legacy app I'm migrating to EF Core 2.0 and one of the first things I did was change migrations to use EF Core 2.0 migrations running at app startup. I was considering changing this to run migrations during VSTS CD Release instead, but it looks like there's a gap in VSTS support.

    Anyone working with VSTS to make dotnet ef easier to run during release? I'd be willing to start that discussion (VSTS forum, or SO).

  7. modified the milestones: , 2.1.0 on Jan 17, 2018
  8. johnnyreilly commented on Mar 4, 2018

    @johnnyreilly

    I'd just like to second what @yzorg said; I think it would be tremendous if deploying EF Core migrations was a "first class citizen" in VSTS.

    I've found myself looking at various solutions:

    In the end it proved too fiddly. I've moved to using migrations when the app starts up. I feel bad but I haven't succeeded with other avenues and I'm out of time. I need to ship.

    This all feels harder than it ought to and I wonder if the team would consider giving this some love?

    Thanks for all your work!

  9. ErikEJ commented on Mar 4, 2018

    @ErikEJ
    Contributor

    Maybe someone in the Community could publish a VSTS extension?

  10. yzorg commented on Mar 8, 2018

    @yzorg

    Maybe this will come with the Core 2.1 support for global installed tools? (Like npm install --global but for dotnet CLI tools.)

    Any plans to add a migration tool as a Core 2.1 global CLI tool?

  11. modified the milestones: 2.1.0, 2.2.0 on Mar 16, 2018
  12. 28 remaining items

  13. modified the milestones: Backlog, 7.0.0 on Oct 22, 2021
  14. ajcvickers commented on Apr 23, 2022

    @ajcvickers
    Contributor

    Note from triage: we believe this is covered by bundles.

  15. removed this from the 7.0.0 milestone on Apr 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions