如何使用ef core 1在UWP中运行迁移

编程入门 行业动态 更新时间:2024-10-15 18:29:26
本文介绍了如何使用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(); }

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

更多推荐

如何使用ef core 1在UWP中运行迁移

本文发布于:2023-11-14 22:17:28,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1588667.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何使用   ef   UWP   core

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!