How to apply migrations from code (EF Core)

前端 未结 3 1271
离开以前
离开以前 2020-12-15 06:42

How to apply migrations from code

for EF6 work code

    Database.SetInitializer(null);
    var settings = new MigrationsConfiguratio         


        
3条回答
  •  醉梦人生
    2020-12-15 06:56

    For Entity Framework Core 1.0.0, ensure you have the Microsoft.EntityFrameworkCore.Relational NuGet package. Then import this namespace:

    using Microsoft.EntityFrameworkCore;
    

    Finally, get hold of a DbContext and run:

    context.Database.Migrate();
    

提交回复
热议问题