首页 > 解决方案 > System.Data.SQLite.EF6.Migrations:加载不存在的错误版本(实体框架 6,非核心)

问题描述

我正在尝试使用代码优先的方法来配置带有库的 .net 4.5 项目

我在 POC 沙箱中成功设置了所有内容,并且运行良好。在生产项目中遵循完全相同的配置,使用 Add-Migration 命令时出现错误。

它显示它需要版本 = 1.0.104.0,但项目使用的是 1.0.112.1。相应的 dll 位于 bin 文件夹中,因此应该可以正确读取它们。另外,我检查了所有可能的位置,并确保所有 dll 文件都是 1.0.112.1,包括 GAC 和 csproj。应该没有地方使用错误版本的 SQLite.EF6

System.IO.FileLoadException: Could not load file or assembly 'System.Data.SQLite.EF6, Version=1.0.104.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'System.Data.SQLite.EF6, Version=1.0.104.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139'
   at System.Data.SQLite.EF6.Migrations.SQLiteMigrationSqlGenerator..ctor()
   at School.ExcelAddin.Data.SQLiteDB.Configuration..ctor() in C:\School.ExcelAddin.Data.SQLiteDB\Configuration.cs:line 16
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Data.Entity.Migrations.Utilities.MigrationsConfigurationFinder.FindMigrationsConfiguration(Type contextType, String configurationTypeName, Func`2 noType, Func`3 multipleTypes, Func`3 noTypeWithName, Func`3 multipleTypesWithName)
   at System.Data.Entity.Infrastructure.Design.Executor.GetMigrationsConfiguration(String migrationsConfigurationName)
   at System.Data.Entity.Infrastructure.Design.Executor.ScaffoldInternal(String name, DbConnectionInfo connectionInfo, String migrationsConfigurationName, Boolean ignoreChanges)
   at System.Data.Entity.Infrastructure.Design.Executor.Scaffold.<>c__DisplayClass0_0.<.ctor>b__0()
   at System.Data.Entity.Infrastructure.Design.Executor.OperationBase.<>c__DisplayClass4_0`1.<Execute>b__0()
   at System.Data.Entity.Infrastructure.Design.Executor.OperationBase.Execute(Action action)

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

Could not load file or assembly 'System.Data.SQLite.EF6, Version=1.0.104.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

标签: c#.netsqlite

解决方案


我自己找到了解决方案。来自 nuget 的System.Data.SQLite.EF6.Migration正在使用来自 nuget 存储库的System.Data.SQLite.EF6System.Data.SQLite的不同(旧)版本。更新SQLiteMigrationSqlGenerator实例时,它指向与当前加载的程序集 (1.0.112.1) 冲突的旧版本System.Data.SQLite.EF6 (v1.0.104.0)。


推荐阅读