-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Comments
We should atleast implement enough that we don't have breaking changes later |
Parts of this depend on #1904 |
Notes from today's design meeting:
// RTM
migration.AddColumn("Id", "Person", "int")
.Annotation("SqlServer:GenerationStrategy", "Identity");
// Post-RTM
migration.AddColumn("Id", "Person", "int")
.ForSqlServer(generationStrategy: SqlServerValueGenerationStrategy.Identity); |
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"
/* ... */); |
...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. |
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. |
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. |
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).
The text was updated successfully, but these errors were encountered: