无法在 VS 2017 .NET Core 上启用 Entity Framework 迁移 [英] Can't enable migrations for Entity Framework on VS 2017 .NET Core

查看:16
本文介绍了无法在 VS 2017 .NET Core 上启用 Entity Framework 迁移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚安装了 VS 2017 并创建了一个新的 Core 项目.在里面,我补充说:

I just installed VS 2017 and created a new Core project. Inside it, I added:

  • Microsoft.EntityFrameworkCore (1.1.0)
  • Microsoft.NETCore.App (1.1.0)

我还创建了一个名为 Models 的文件夹,其中包含一个类.然后,我进入 Package Manager Console 并执行 enable-migrations 以便 VS 为我创建所需的文件.但是,我得到了以下错误,而不是所需的文件.

I also created a folder called Models with a class in it. Then, I went to the Package Manager Console and executed enable-migrations so that VS will create the files needed for me. However, instead of the needed files, I got the following error.

术语enable-migration"未被识别为 cmdlet、函数、脚本文件或可运行程序的名称.检查名称的拼写,或者如果包含路径,请验证路径正确,然后重试.

The term 'enable-migration' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

我应该在这里做什么?

我似乎不走运谷歌搜索.这是一个非常不寻常的组合(Core VS17 和 EF),因此几乎没有关于该主题的信息.一些指南谈到手动编辑 package.json 有点困难,因为 VS 2017 似乎升级了核心,因此 dotnet restore 不寻找它,而是寻找一个 xxx.csproj.

I seem to be out of luck googling. It's a very unusual combination (Core VS17 and EF) so there's virtually no info on the subject. Some guides talk about editing package.json by hand which is kind of hard because VS 2017 seems to upgrade the Core so that dotnet restore doesn't look for it but rather for a xxx.csproj.

总之,我很困惑,很不确定如何解决这个问题.

In summary, I'm confused and quite uncertain how to bite the problem.

推荐答案

EF Core 不再有 Enable-Migrations 命令.默认"启用迁移.使用 Add-Migration 添加新的迁移.

EF Core does not have Enable-Migrations command anymore. Migrations are enabled "by default". Add new migration with Add-Migration.

关于包管理器命令的文档在这里

Documentation about package manager commands is here

这篇关于无法在 VS 2017 .NET Core 上启用 Entity Framework 迁移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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