Primary migration of Entity Framework Core 1.0 using code?

In previous versions of the Entity Framework, code migrations could be controlled programmatically using the DbMigrator class (for example, check and apply available migrations). Does this class still exist somewhere or is there a functional replacement? I found a message in an earlier version of RC that indicated a replacement, but that also seems to be missing in Core 1.0. I can control my migrations through the CLI without any problems, but I think that I need firmware for scripting special tools.

+5
source share
1 answer

A functional replacement can be found in several places, most notably in the API found in the Microsoft.EntityFrameworkCore.Migrations namespace.

Some places to search:

With the exception of IMigrator.Migrate , using these APIs usually means pulling the service out of the internal EF Core service container. This is done by calling .GetService<TService>() in your dbcontext.

Example:

 var migrator = context.GetService<IMigrator>().Migrate(); 
+6
source

All Articles