簡體   English   中英

正在運行Dotnet EF遷移,添加…運行時會生成FileNotFoundException

[英]Running Dotnet EF migrations add … generates FileNotFoundException when run

產生的錯誤如下。

System.IO.FileNotFoundException: Could not load file or assembly 'System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes' or one of its dependencies. The system cannot find the file specified.
File name: 'System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes'
   at Microsoft.DotNet.ProjectModel.ProjectReader.ReadProject(Stream stream, String projectName, String projectPath, ProjectReaderSettings settings)
   at Microsoft.DotNet.ProjectModel.ProjectReader.GetProject(String projectPath, ProjectReaderSettings settings)
   at Microsoft.EntityFrameworkCore.Tools.DispatchCommand.<>c__DisplayClass2_0.<Create>b__0()
   at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
   at Microsoft.EntityFrameworkCore.Tools.Program.Main(String[] args)
Could not load file or assembly 'System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes' or one of its dependencies. The system cannot find the file specified.

任何DOTNET EF命令都會發生此錯誤(甚至--help)

我們有可以在其中運行的多台計算機,但是其中兩台計算機出現上述錯誤,這是否令人沮喪?

我什至嘗試僅從Github安裝ProjectModel組件都沒有成功

感謝您對如何解決此問題的任何幫助

我遇到了這個問題(以及運行其他dotnet命令的其他類似錯誤。對我來說,這是因為安裝了較舊的RC1和SDK。我從添加/刪除程序中刪除了所有內容,並刪除了c:\\program filesdotnetDNX目錄c:\\program files ,然后我重新安裝並開始工作。

我嘗試了卸載和刪除所有DNX和DOTNET目錄的建議,但無濟於事。

然后我做了更多搜索,找到了答案。 我必須將我的工具-實體框架配置更改為以下內容

"Microsoft.EntityFrameworkCore.Tools": {
  "version": "1.0.0-preview1-final",
  "imports": "portable-net451+win8"

},

然后我必須按照本文鏈接https://github.com/aspnet/EntityFramework/issues/5458#issuecomment-221912806清除Entity Framework的緩存

然后,我需要從項目中刪除Microsoft.EntityFrameworkCore.SqlServer的引用,並讓VS通過重新加載來修復引用本身

在此之后,Build解決了這個問題,我可以再次運行dotnet ef命令

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM