Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrations: Multiple providers #1825

Closed
rowanmiller opened this issue Mar 13, 2015 · 7 comments
Closed

Migrations: Multiple providers #1825

rowanmiller opened this issue Mar 13, 2015 · 7 comments
Labels
closed-out-of-scope This is not something that will be fixed/implemented and the issue is closed. type-enhancement

Comments

@rowanmiller
Copy link
Contributor

In EF7 we're going all in with provider specific migrations, so if I target SQL Server and PostreSql then I need to gen two sets of migrations. Our migrations commands aren't setup to deal with two (or more) sets of migrations though.

We probably need a first class concept of a provider (also needed for reverse engineer) and then we can have migrations identify which provider they are for (possibly in the attribute we use to identity which context they are for).

@rowanmiller
Copy link
Contributor Author

We should atleast implement enough that we don't have breaking changes later

@bricelam
Copy link
Contributor

Parts of this depend on #1904

@bricelam
Copy link
Contributor

Notes from today's design meeting:

  • We can have one model differ that diffs "all" annotations
    • Annotations can be filtered by provider prefix for all participating providers
  • Some core/relational metadata should be overridable per provider (e.g. StoreType & DefaultExpression)
  • Some core/relational metadata doesn't need to be overridable (e.g. DefaultValue)
  • Post-RTM, providers can optionally scaffold their annotations as extension methods:
// RTM
migration.AddColumn("Id", "Person", "int")
    .Annotation("SqlServer:GenerationStrategy", "Identity");

// Post-RTM
migration.AddColumn("Id", "Person", "int")
    .ForSqlServer(generationStrategy: SqlServerValueGenerationStrategy.Identity);

@bricelam
Copy link
Contributor

I chatted with @rowanmiller today, and we decided to do the following for RTM.

We'll scaffold migrations that are specific to the active provider. For example, given the following model...

modelBuilder.Entity<Person>()
    .SqlServerTable("People")
    .SqliteTable("people");

...the following migration would be generated if SQL Server was the active provider at design-time.

migrationBuilder.CreateTable(
    name: "People"
    /* ... */);

However, to unblock people from hand-crafting migrations that can run against multiple providers, we'll implement #2258. With that, you could write a migration that looks something like this:

migrationBuilder.CreateTable(
    name: activeProvider == "EntityFramework.SqlServer"
        ? "People"
        : "people"
    /* ... */);

@rowanmiller
Copy link
Contributor Author

...and once we have everything working we can look at scaffolding something like the conditional code in the final snippet when there are multiple providers registered... but that will presumably be post 7.0.0.

Also worth noting that by having the current provider accessible to the migration code we are already better than EF6, so we easily clear the "EF6 parity" bar.

@bricelam bricelam changed the title Migrations: Need proper story for different migration sets for different providers Migrations: Multiple providers May 27, 2015
@bricelam
Copy link
Contributor

The investigation work here is done; I have enough context to avoid breaking changes in the future. We can move this issue to the backlog now.

@rowanmiller
Copy link
Contributor Author

We already have the flag to allow you to do different things based on the active provider. We think this is enough and we don't need to scaffold for multiple providers.

@rowanmiller rowanmiller added the closed-out-of-scope This is not something that will be fixed/implemented and the issue is closed. label Jan 13, 2017
@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-out-of-scope This is not something that will be fixed/implemented and the issue is closed. type-enhancement
Projects
None yet
Development

No branches or pull requests

3 participants