efcore icon indicating copy to clipboard operation
efcore copied to clipboard

Enhancement: Run migrations from code when developing in a Code First approach?

Open cgideon opened this issue 11 years ago • 2 comments

Please accept my apologies if this is not the correct place to submit this.

I'm using a nightly build version of EF7, 7.0.0-rc1-16305 from earlier this week in order to get it to work with an SQLite database correctly. In EF7 7.0.0-Beta8 you can do something like:

using(var db = new ContextClass())
{
    db.Database.Migrate();
}

But this seems to have been removed.

I can run the migrations and update the database from the Package Manager Console in VS 2015, but I'm needing to be able to run any new migrations on application startup via code as this is a WPF desktop application and users will not be able to run commands from the CMD in order to get the DB set up.

Is this something that is going to be supported or do I need to write a custom runner? If I need to write a custom writer is this a feature you would like included in the framework?

cgideon avatar Nov 13 '15 15:11 cgideon

@cgideon that API is still there in RC... it's an extension method, so make sure you have Microsoft.Data.Entity namespace imported.

rowanmiller avatar Nov 13 '15 16:11 rowanmiller

@rowanmiller Ah, I see it. I apologize for missing that. Thank you for pointing that out!

cgideon avatar Nov 13 '15 16:11 cgideon