我不知道我是如何使用 EntityFramework.Commands(也是 v7.0.0-rc1-final)在 EntityFramework.Core(v7.0.0-rc1-final) 中运行迁移的。
当我添加迁移 (Add-Migration) 时,迁移就会创建。然后,当我进入Update-Database时,所以PM控制台返回:
Update-Database should not be used with Universal Windows apps. Instead, call DbContext. Database. Migrate () at runtime.
但是 Context.Database 不包含方法 Migrate()。所以不能指定这个命令。在我看来,这是一个错误。
最佳答案
在 RC1 中,确保您有 using Microsoft.Data.Entity;
在文件中。 Migrate() 是一种扩展方法,在您安装关系提供程序(例如 EntityFramework.Sqlite)时可用。
using (var db = new BloggingContext())
{
db.Database.Migrate();
}
见 https://docs.efproject.net/en/latest/platforms/uwp/getting-started.html
关于win-universal-app - 如何使用 ef core 1 在 UWP 中运行迁移,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36044416/