如何使用ef core 1在UWP中运行迁移 [英] How to run a migration in UWP using ef core 1

查看:89
本文介绍了如何使用ef core 1在UWP中运行迁移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道如何使用EntityFramework.Commands(也为v7.0.0-rc1-final)在EntityFramework.Core(v7.0.0-rc1-final)中运行迁移。
当我添加迁移(Add-Migration)时,会创建迁移。然后,当我输入Update-Database时,PM控制台将返回:

I don't know how I have run the migration in EntityFramework.Core(v7.0.0-rc1-final) using EntityFramework.Commands(also v7.0.0-rc1-final). When I add the migration (Add-Migration) so migration creates. Then, when I enter the Update-Database, so the PM console returns:


Universal Windows应用程序不应使用Update-Database。而是,调用DbContext。数据库。在运行时迁移()。

Update-Database should not be used with Universal Windows apps. Instead, call DbContext. Database. Migrate () at runtime.

但是Context.Database不包含方法Migrate()。因此无法指定此命令。在我看来,这是一个错误。

But the Context.Database does not contain method Migrate(). So this command cannot be specified. It seems to me that this is a bug.

推荐答案

在RC1中,确保使用Microsoft的 .Data.Entity; 在文档中。 Migrate()是一种扩展方法,当您安装关系提供程序时,例如EntityFramework.Sqlite。

In RC1, make sure you have using Microsoft.Data.Entity; in the document. Migrate() is an extension method that is available when you install a relational provider, such as EntityFramework.Sqlite.

        using (var db = new BloggingContext())
        {
            db.Database.Migrate();
        }

请参见 https://docs.efproject.net/en/latest/platforms/uwp/getting-started.html

这篇关于如何使用ef core 1在UWP中运行迁移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆