Skip to content

Fully embrace provider-specific migrations #16406

Description

@ajcvickers

Current situation

Scaffolded migrations target a specific database provider. This means that it is not in general possible to scaffold a migration against one provider and then use it with another provider.

However, we try to keep the migration "relatively agnostic to the provider" so that there should be only small differences between the migrations for different providers. The most obvious case of this (and perhaps the only one) is that we don't put store types obtained from a type mapping in the migration, because they are very provider-specific. But this has been a source of bugs such as #12212.

So if we drop the "relatively agnostic" part, then we can make provider-specific migrations more robust by removing a source of complexity and bugs.

What changed?

So why did we not take this path already? Well I, for one, believed that it was relatively easy to take two migrations and edit them together into a single migration with some conditional code. Indeed, we even documented this. But it turns out that this isn't easy, because if you want to maintain a full set of migrations that can go up/down for multiple providers, then you also need to merge the model snapshot and the code-behind, both of which are also provider specific. It's hard to believe that many people are doing this, let alone doing it right.

How to we make the experience good

The other way to handle migrations for multiple providers is to have multiple parallel sets of migrations, one for each provider. This is also documented.

However, I think we could make this easier (post-3.0) by annotating the migration with the provider it targets and then adding some support in tooling. For example, #15174 is about throwing if the migration was created for a different provider. But we could extend this to find the right migration from multiple annotated with different provider names.

What should we do now?

Proposal:

Activity

  1. ajcvickers commented on Jul 2, 2019

    @ajcvickers
    ContributorAuthor
  2. ajcvickers commented on Jul 5, 2019

    @ajcvickers
    ContributorAuthor

    Notes from triage:

  3. modified the milestones: Discussions, Backlog on Jul 5, 2019
  4. self-assigned this
    on Jul 5, 2019
  5. self-assigned this
    on Nov 5, 2019
  6. modified the milestones: Backlog, 5.0.0 on Nov 13, 2019
  7. removed this from the 5.0.0 milestone on Mar 12, 2020
  8. 18 remaining items

  9. modified the milestones: 7.0.0, Backlog on Apr 23, 2022
  10. removed their assignment
    on Jul 8, 2023
  11. removed their assignment
    on Aug 31, 2024
  12. added theissue type on Jun 15, 2025
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

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions