gpt4 book ai didi

entity-framework - 无法启用迁移。抛出 System.BadImageFormatException : Could not load file or assembly

转载 作者:行者123 更新时间:2023-12-04 12:22:21 24 4
gpt4 key购买 nike

我无法启用 EF 迁移!

使用包管理器控制台,它会抛出以下内容:
PM> Enable-Migrations
System.BadImageFormatException: Could not load file or assembly 'MyApp' or one of its dependencies. Index not found. (Exception from HRESULT: 0x80131124)
File name: 'MyApp' ---> System.BadImageFormatException: Index not found. (Exception from HRESULT: 0x80131124)
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection)
at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.Load(String assemblyString)
at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.LoadAssembly()
at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.FindType[TBase](String typeName, Func
2 过滤器,功能 2 noType, Func 3 multipleTypes, Func 3 noTypeWithName, Func 3 multipleTypesWithName)
在 System.Data.Entity.Migrations.Design.ToolingFacade.GetContextTypeRunner.RunCore()
在 System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.Run()

Could not load file or assembly 'MyApp' or one of its dependencies. Index not found. (Exception from HRESULT: 0x80131124)

还:
1. 我的默认项目(在 PM CONSOLE 中)是“MyApp”
2. 解决方案只有“MyApp”
3.从DbContext继承的类在'MyApp.Models'中
4.我也尝试创建一个新的解决方案,然后将所有类复制粘贴到它,它抛出了同样的错误

怎么了?
过去我曾经在这个项目中启用了迁移,但两天后我删除了其中的所有迁移内容,因为它不是必需的。但现在我真的需要它们

最佳答案

我只是遇到了同样的问题。
System.BadImageFormatException的原因是因为我依赖于 x64 DLL(在我的例子中是 Magick.NET-x64.dll)。强制项目以 32 位构建解决了它。

  • 选择您的 网络项目
  • 转至 属性
  • 选择 构建 标签
  • 更改 平台目标 :来自 x64 任意 CPU

  • 希望这对其他人有帮助。

    关于entity-framework - 无法启用迁移。抛出 System.BadImageFormatException : Could not load file or assembly,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16874451/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com