c# - "the term ' 添加迁移 ' is not recognized as the name of a cmdlet" Visual Studio 2019

标签 c# asp.net-core entity-framework-core code-first

enter image description here
enter image description here

我正在尝试使用 Entity Framework 工作核心并打开一个新的 asp.net 核心项目。当我尝试通过 nuget 包管理器安装 Microsoft.EntityFrameworkCore.SqlServer 时,出现以下错误。

包 Microsoft.EntityFrameworkCore.SqlServer 3.0.0 与 net461 (.NETFramework,Version=v4.6.1) 不兼容。包 Microsoft.EntityFrameworkCore.SqlServer 3.0.0 支持:netstandard2.1 (.NETStandard,Version=v2.1)

当我点击它时,我被发送到 .csproj 文件。

在该文件中,我将目标框架从<TargetFramework>net461</TargetFramework><TargetFramework>netstandard2.1 </TargetFramework>正如错误所暗示的那样。

这样做可以消除错误,但是当我在包管理器控制台中使用命令“add-migration”时,出现此错误。

“术语 'add-migration' 不被识别为 cmdlet 的名称”

我不确定接下来要做什么。请帮忙。我希望我已经清楚地解释了这个问题。

删除 project.assets 文件或更新 nuget 包管理器并使用命令“enable-migrations”也没有奏效。

enter image description here
enter image description here

最佳答案

以下帮助我将缺少的工具添加到 .net core 3.1

  • 安装包 Microsoft.EntityFrameworkCore.Tools
  • 更新包 Microsoft.EntityFrameworkCore.Tools
  • Get-Help about_EntityFrameworkCore

  • 从这里 Blog

    关于c# - "the term ' 添加迁移 ' is not recognized as the name of a cmdlet" Visual Studio 2019,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58233950/

    相关文章:

    c# - 包含 SQL 的电子邮件

    c# - 通过更改数据表中可用的数据来填充数据网格

    c# - SQL 到 LINQ - Case 语句

    c# - Unity - SendMessage 但用于变量而不是函数/方法

    c# - 在控制台应用程序中捕获鼠标滚轮事件

    asp.net-core - ASP .NET vNext MVC 没有移交给管道中的下一个?

    asp.net-core - IdentityServer4 登录接口(interface)

    asp.net-core - 使用 UseStatusCodePagesWithReExecute 时,状态代码不会发送到浏览器

    c# - EF Core 中具有自动序列化/反序列化的自定义类型

    visual-studio-2015 - 在 VS2015 中从包管理器控制台安装 Entityframework 7 时出现 Nuget 错误 "Object reference not set to an instance of an object"