4

I'd like to call these migrations from a script and while there's plenty of information on how to do that with Entity Framework standard there's very little with Entity Framework Core.

I believe that this is the command that I need but I'm not sure on how to instantiate it properly or where the underlying classes are.

https://github.com/aspnet/EntityFrameworkCore/blob/7c64310a66ad04d04c43edaa70dc9e3963cb493f/src/ef/Commands/DatabaseUpdateCommand.Configure.cs

Edit: There seems to be some confusion about what it is I'm trying to do. Here is an example in the standard Entity Framework. However, upon first look there doesn't seem to be equivilent to DbMigrator in entity framework core.

https://romiller.com/2012/02/09/running-scripting-migrations-from-code/

4
  • Do you mean running Update-Database from Package Manager Console? Commented May 14, 2018 at 9:05
  • No. I mean calling it from a script I wrote myself. Not from the CLI. Commented May 14, 2018 at 9:44
  • Do you mean run pending migrations in Startup? Commented May 14, 2018 at 11:41
  • Please see my edit. Commented May 14, 2018 at 12:41

1 Answer 1

12

We made it easier in EF Core:

using (var db = new MyDbContext())
{
    db.Database.Migrate();
}
Sign up to request clarification or add additional context in comments.

2 Comments

Absolutely beautiful mate. I'll give it a shot!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.