win-universal-app - 如何使用 ef core 1 在 UWP 中运行迁移

标签 win-universal-app entity-framework-core

我不知道我是如何使用 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/

相关文章:

c# - 为什么我无法将 sqlite 文件上传到 OneDrive?

c# - SqlException : Cannot insert explicit value for identity column in table 'Tasks' when IDENTITY_INSERT is set to OFF

c# - Entity Framework 核心 : how to map multiple objects of the same type

c# - 全屏WP通用应用

.net - 通用应用的主题资源

toast - 显示本地 Toast 通知

asp.net-core - Asp.net Core 通过用户 ID 获取用户

mysql - 错误 CS1061 'DbContextOptionsBuilder' 不包含 'UseMySql' 的定义

c# - 使用 EF Core 2 和 Nlog 记录生成的 SQL

C# - HttpRequest 请求第二次登录凭据