"dotnet ef database update" programatically with Entity Framework Core

asp.net-core c# entity-framework entity-framework-core

Question

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/

1
4
5/14/2018 12:41:11 PM

Accepted Answer

We made it easier in EF Core:

using (var db = new MyDbContext())
{
    db.Database.Migrate();
}
8
5/14/2018 3:44:32 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow