由于dotnet ef dbcontext --json失败,因此无法在Visual Studio 2019中列出实体框架迁移 [英] Cannot list Entity Framework Migrations in Visual Studio 2019 due to dotnet ef dbcontext --json failure

查看:254
本文介绍了由于dotnet ef dbcontext --json失败,因此无法在Visual Studio 2019中列出实体框架迁移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用.NET Core 3.0的ASP.NET Core 3.0项目。我最近将VS 2019升级到版本16.4.1。

I have an ASP.NET Core 3.0 project that uses .NET Core 3.0. I have recently upgraded VS 2019 to version 16.4.1.

我使用Visual Studio中的Web Publish在各种环境上部署应用程序,但是由于EF迁移(尝试查找数据库上下文失败):

I use Web Publish from Visual Studio to deploy the application on various environments, but this failed after the upgrade due to EF migrations (trying to find the db contexts failed):


dotnet ef dbcontext --json失败

dotnet ef dbcontext --json failure

运行 dotnet工具还原以使 dotnet-ef命令可用。

Run "dotnet tool restore" to make the "dotnet-ef" command available.

我试图理解

dotnet tool restore




找不到清单文件。有关搜索位置的列表,请在工具名称前的$ -b选项中指定
。没有工具被恢复。

Cannot find a manifest file. For a list of locations searched, specify the "-d" option before the tool name. No tools were restored.



dotnet tool install --global dotnet-ef




工具'dotnet-ef'已经安装。

Tool 'dotnet-ef' is already installed.



dotnet tool list




包装ID版本命令清单

Package Id Version Commands Manifest

(此列表中没有项目)

(there are not items in this list)

dotnet-ef --version




实体框架核心.NET命令行工具
3.1.0

Entity Framework Core .NET Command-line Tools 3.1.0



dotnet --version




3.1.100

3.1.100

我是否需要升级才能将所有内容升级到3.1?如果可能的话,我想将其推迟(我必须在多个环境中执行,并且计划在以后的时间进行。)

Do I need to upgrade to upgrade everything to 3.1? I would like to postpone this if possible (I have to do this on multiple environments and it is scheduled at a later time).

注意:我也有Visual Studio 2017,并且在配置发布配置文件时可以正确发现Entity Framework Migrations上下文。

Note: I also have Visual Studio 2017 and Entity Framework Migrations contexts are properly discovered when configuring the publishing profile.

问题:如何解决无法在Visual Studio 2019中列出实体框架迁移由于dotnet ef dbcontext --json失败?

Question: How to solve Cannot list Entity Framework Migrations in Visual Studio 2019 due to dotnet ef dbcontext --json failure?

推荐答案

我遇到了同样的问题(在Visual Studio 2019更新之后),在我的电脑上有此问题,但在另一台电脑上没有。文件全部相等(通过git检查),VS2019在某处缓存了某些东西,这很不好。

I had the same problem (after an update of visual studio 2019), on my pc there is this problem but in another pc no. The files are all equal (checked via git), VS2019 cache something somewhere and this is bad.

1检查默认连接字符串是否正确。

1 Check the default connection string is ok.

2检查是否安装了dotnet ef。在核心3.1中,您必须安装: dotnet工具安装-g dotnet-ef

2 Check if dotnet ef is installed. In core 3.1 you must install: dotnet tool install -g dotnet-ef

3关闭VS,删除文件夹< yourproject> / Properties (如果需要,请备份它),打开VS,清理解决方案,然后再次导入发布文件。

3 Close VS, delete the folder <yourproject>/Properties (backup it if you want), open VS, clean solution and import the publish file again.

这篇关于由于dotnet ef dbcontext --json失败,因此无法在Visual Studio 2019中列出实体框架迁移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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