【问题标题】:EF Core migration errors with the located assembly's manifest definition does not match the assembly reference所定位程序集的清单定义的 EF Core 迁移错误与程序集引用不匹配
【发布时间】:2018-08-31 19:52:33
【问题描述】:

我正在尝试使用 SQL Operations Studio 从 VS 代码的终端生成数据库,每当我尝试生成迁移时,都会出现此错误。

dotnet ef migrations add init

未处理的异常:System.IO.FileLoadException:无法加载文件或程序集'/usr/local/share/dotnet/sdk/2.1.401/DotnetTools/dotnet-ef/2.1.2/tools/netcoreapp2.1/任何/工具/netcoreapp2.0/any/ef.dll'。找到的程序集的清单定义与程序集引用不匹配。 (HRESULT 异常:0x80131040)

这就是我的.csproj 现在的样子

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.1</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.1.2" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.1.2" />
  </ItemGroup>
</Project>

有什么解决方法吗?

【问题讨论】:

  • 你有.core 2.1.2 框架吗?
  • @viveknuna 是的,我有。
  • 我认为你可以在 EF Core 中提出错误
  • 我解决了在&lt;RuntimeIdentifier&gt;osx.10.12-x64&lt;/RuntimeIdentifier&gt; 标签内添加&lt;RuntimeIdentifier&gt;osx.10.12-x64&lt;/RuntimeIdentifier&gt; 的问题

标签: c# .net-core entity-framework-core


【解决方案1】:

如果您将Microsoft.EntityFrameworkCore.Design 包添加到错误的项目中,也会发生这种情况。

我将包添加到project A (netcore)。后来我决定让项目 A 以netstandard 为目标。然后我创建了引用project A (now netstandard)Project B (netcore)

当我尝试在项目 B 中创建迁移时,构建成功但迁移会失败,因为在 A 而不是 B 中引用了 Microsoft.EntityFrameworkCore.Design。将 nuget 引用移动到 B 可以解决问题。

【讨论】:

    猜你喜欢
    • 2020-12-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-06-10
    • 2015-01-29
    • 2021-07-17
    • 2018-10-13
    • 1970-01-01
    相关资源
    最近更新 更多