-
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
EF Core Migrations Configuration #7407
Comments
Automatic migrations has been removed from EF7 and currently there is no support for this feature. I don't think this one will be a good idea at all !!! |
@ekarimi I made considerations regarding explicit migrations here and I don't believe this approach will solve the problems in relational databases in team work. |
Are you looking for something like #3053, or is your scenario different? |
@bricelam I understood the idea, it'll be something like:
Some Powershell script updates the Snapshot, drop the database, re-scaffold the initial migration and redo a new database with (probably) the seeding process in the end. Sounds great, but I believe that the initial code migration should have a default name, to source control purposes. Please note that this doesn't replace the migrations configuration, as I suggested. It would be great if data loss can be configurable. |
Configuration of anything migrations related is now done in protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder
.UseSqlServer(@"Server=.\SQL2016;Database=Test;Trusted_Connection=True;", sqlOptions =>
sqlOptions.MigrationsAssembly("My.System.Migrations")
.MigrationsHistoryTable("_Migrations"));
} Data loss settings only applied to automatic migrations, since scaffolded ones were never run automatically and you could review them before applying. |
Also, in EF Core, we'll warn during Add-Migration if any scaffolded operation would result in data loss. |
@rowanmiller Can I configure data loss tolerance using this method? |
@bricelam Would be possible to use a parameter like |
The migrations will always execute. The warning occurs while scaffolding. EF Core is very extensible since you can customize and replace any service. I'm sure you could serialize the data loss flag in the C# and throw during migrate if it's present. |
@bricelam Okay, I'll dig into the sources and try to implement something. You mentioned the steps to obtain the differences in other issue. I'll use this as a guide to extend EF Core in some way. |
I didn't find a way to configure the Migrations like in EF6.
Is there something planned in EF Core to replace this feature?
The text was updated successfully, but these errors were encountered: