Skip to content

Migration scripts are always generated for "Development" environment #11950

Closed as not planned

Description

@macsux

dotnet ef migrations script always defines Development environmental variable. For applications that use InMemory EF provider when running in Development mode by defining multiple Configure{EnvironmentName}Services blocks this creates a problem, especially when trying to publish to Azure.

Exception message:
Microsoft.EntityFrameworkCore.InMemory is not a Relational provider and therefore cannot be use with Migrations.

Steps to reproduce

Problem is visible in https://github.com/dotnet-architecture/eShopOnWeb when trying to publish on azure and apply migrations on publish.

Further technical details

EF Core version: 2.0.2
Database Provider: Mixed
Operating system:
IDE: Visual Studio 2017 15.6.2

Activity

  1. bricelam commented on May 9, 2018

    @bricelam
    Contributor

    You can manually set the ASPNETCORE_ENVIRONMENT environment variable before calling dotnet ef.

  2. macsux commented on May 9, 2018

    @macsux
    Author

    I don't call dotnet ef directly - it's being called for me by Visual Studio during a publish to azure.

  3. bricelam commented on May 9, 2018

    @bricelam
    Contributor

    Interesting. We may need to add an option to the publish dialog for this...

  4. divega commented on May 10, 2018

    @divega
    Contributor

    @bricelam to provide workaround. @divega to follow up about how this works on deployment.

  5. self-assigned this
    on May 10, 2018
  6. added this to the 2.2.0 milestone on May 10, 2018
  7. bricelam commented on May 11, 2018

    @bricelam
    Contributor

    To work around this, you can set the environment variable before launching Visual Studio when publishing:

    SET ASPNETCORE_ENVIRONMENT=Production
    devenv
  8. removed their assignment
    on May 11, 2018
  9. divega commented on Jul 25, 2018

    @divega
    Contributor

    @bricelam, should we treat this as a duplicate of #8695? Otherwise can you remind me what this one is about?

  10. bricelam commented on Jul 26, 2018

    @bricelam
    Contributor

    We were going to follow up with the Web Publish team about adding an option in the UI to specify the environment.

  11. removed this from the milestone on Sep 11, 2018
  12. 10 remaining items

  13. self-assigned this
    on Nov 3, 2021
  14. removed their assignment
    on Jul 8, 2023
  15. GeorgeAlexandruD commented on Sep 20, 2023

    @GeorgeAlexandruD

    @rick

    To work around this, you can set the environment variable before launching Visual Studio when publishing:

    SET ASPNETCORE_ENVIRONMENT=Production
    devenv

    Or on the Properties > Debug debug tab set it

    image

    And? how do I change between environments? You can't just say "this is solution" but then not show how it works.

    If I manually change the variable (ew!) then it stays changed no matter what mode I run visual studio in. Please be specific, and clear, in your answers. Also when writing @microsoft docs. We ain't all geniuses with 30 years experience.

  16. rick commented on Oct 13, 2023

    @rick

    bladdow

  17. added theissue type on Jun 15, 2025
  18. AndriySvyryd commented on Aug 13, 2026

    @AndriySvyryd
    Member

    This isn't something that can be fixed on the EF Core side, we recommend using CLI

  19. removed this from the Backlog milestone on Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions