专业吃瓜摸鱼
2020-04-12 16:34
求问各位大神为什么会出现如图问题啊?
已经安装了Microsoft.EntityFramework / Microsoft.EntityFramework.Tools / Microsoft.EntityFramework.SqlServer
hello 同学好啊,问题解决了吗?这是个比较少见的问题。搜了一下网上的答案,发现类似的问题,https://github.com/dotnet/efcore/issues/16386
帖主也出现了同样的问题,后来他卸载了visual studio 的 Azure developmen组件,就解决了。后来也有人回复说碰上同样的问题,用vs 2019就报错,用vs 2017就可以。后来还有个人说,他的电脑是惠普的,在他电脑上运行就不行,拿到别人的电脑就可以。。。。总之,这个问题似乎有很多人都碰到过。
然后我看了,他们的解决方式,感觉都不太靠谱。
不过有两个人的解决方式值得参考一下,他们说vs 2019不行,但是vs 2017就可以,所以我在想或许真的是visual studio所导致的问题。
所以,你可以做一下两个尝试
下载个vs 2017试试看。
使用 dotnet cli(命令行)代替使用 package-manage-console
)打开命令行,全局安装 dotnet-ef: dotnet tool install --global dotnet-e
)关闭命令行,重新打开,cd进入项目文件夹
)输入dotnet ef命令:dotnet ef migrations add InitialMigration
)如果成功,继续输入命令:dotnet ef database update
确实有点奇怪,试试下载课程的源码试试看:https://github.com/Yaduo/LanzhouBeefNoodles,如果还有问题,留言下来,我再看看
https://cloud.tencent.com/developer/ask/222513
这个帖子给了一个解决方案:
尝试将此添加到.csproj文件中
<PropertyGroup> <GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles> </PropertyGroup>
我使用的这个方法解决的问题
换到3.1之后报错
PM> add-migration InitialMigration
Build started...
Build succeeded.
System.IO.FileLoadException: Could not load file or assembly 'netstandard, Version=2.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'netstandard, Version=2.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.AddMigration(String name, String outputDir, String contextType)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigrationImpl(String name, String outputDir, String contextType)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass3_0`1.<Execute>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
Could not load file or assembly 'netstandard, Version=2.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
把Project.dll也复制过去之后报错
Your startup project 'project' doesn't reference Microsoft.EntityFrameworkCore.Design. This package is required for the Entity Framework Core Tools to work. Ensure your startup project is correct, install the package, and try again.
令人头秃 已经安装了一下这些 还是不行
之前错误显示不全是因为路径有中文...改成英文之后报错是
PM> add-migration InitialMigration
The specified deps.json [F:\project\project.deps.json] does not exist
我的该文件在F:\project\bin\Debug\netcoreapp2.2里面 试着把他复制到F:\project之后报错为
Error:
An assembly specified in the application dependencies manifest (project.deps.json) was not found:
package: 'project', version: '1.0.0'
path: 'project.dll'
谁来救救孩子...
打造你的第一个ASP.NET5 MVC网站应用
19277 学习 · 194 问题
相似问题