Skip to content

Document how to execute migrations without the .NET Core SDK installed #807

Closed as not planned

Description

@jholovacs

I keep getting told the project can't be found. Why is the project necessary? The code is contained in the dlls. How do I take my published code as an artifact and run the database update?


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Activity

  1. jsancho commented on Aug 17, 2018

    @jsancho

    Not that straightforward to do manually.
    We have ended up using the VSTS task from Ben Day, he's also published scripts for win/linux to execute the migrations.
    https://www.benday.com/2018/07/05/deploy-entity-framework-core-2-1-migrations-from-a-dll/

  2. added this to the Backlog milestone on Sep 7, 2018
  3. ajcvickers commented on Oct 1, 2018

    @ajcvickers
    Contributor

    See also the discussion here: dotnet/efcore#13339

    Specifically, it would be useful to:

    • Make sure that people understand that the dotnet tools can be used if the SDK is installed
    • For people who can't install the SDK, link to these blog posts
    • Add benday's tool to the EF core extensions document.
  4. bricelam commented on Jan 18, 2019

    @bricelam
    Contributor

    benday's tool: Build & Release Tools

  5. jholovacs commented on Jan 18, 2019

    @jholovacs
    Author

    I'm doing a workaround now by creating an idempotent migration script in my build:

    dotnet ef migrations script --idempotent --output "$(Build.ArtifactStagingDirectory)/migrations.sql" --context MySolution.MyDataAccessProject.Services.AnalysisDbContext
    

    ...then I run this like any other sql script in a powershell window. It seems a little kludgy, but... eh, it works.

  6. changed the title [-]How to do a migration with published code?[/-] [+]Document how to execute migrations without the .NET Core SDK installed[/+] on Aug 28, 2019
  7. modified the milestones: Backlog, 5.0.0 on Jan 15, 2020
  8. modified the milestones: 5.0.0, Backlog on Oct 29, 2020
  9. zordark commented on Nov 23, 2020

    @zordark

    We are working in .net 4.8 environment and using next workaround.
    In csproj file with migrations we are coping all dependencies to output folder:

        <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.9">
          <IncludeAssets>compile; runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
          <PrivateAssets>all</PrivateAssets>
          <Publish>true</Publish>
        </PackageReference>
         ...
        <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.9" GeneratePathProperty="true">
          <PrivateAssets>all</PrivateAssets>
          <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
        </PackageReference>
        ...
       <ItemGroup>
          <None Include="$(PkgMicrosoft_EntityFrameworkCore_Tools)\tools\net461\any\ef.exe" CopyToOutputDirectory="PreserveNewest" />
       </ItemGroup>
    

    So we don't need to know where is Microsoft.EntityFrameworkCore.Tools installed and we can run migrations much easily.
    With powershell something like that:

    .\ef.exe database update --assembly <assembly name>.dll
    

    with dotnet core you can do the same, all you need is replace ef.exe path with ef.dll path, something like that: \tools\netcoreapp2.0\any\ef.dll

  10. removed their assignment
    on Jul 8, 2023
  11. AndriySvyryd commented on Aug 5, 2026

    @AndriySvyryd
    Member

    Migration bundles, introduced in EF Core 6, provide the requested deployment artifact. A bundle contains the compiled migration code, does not require project source or dotnet ef on the deployment machine, and can include the .NET runtime when generated with --self-contained.

  12. removed this from the Backlog milestone on Aug 5, 2026
  13. added a commit that references this issue on Aug 11, 2026
    bb42937
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions