无法加载文件或程序集’MySql.Data

前端之家收集整理的这篇文章主要介绍了无法加载文件或程序集’MySql.Data前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我正在开发ASp.net mvc 5中的应用程序并使用代码优先方法.

当我尝试启用迁移时,它会抛出一个错误.我在参考文献中找到了MySQL.Data.dll.可能是什么问题?

上传source at here.

如果可能的话,请指导我.谢谢

错误在下面提到;

enable-migrations -contexttypename SMSContext
Checking if the context targets an existing database...
System.IO.FileLoadException: Could not load file or assembly 'MysqL.Data,Version=6.9.3.0,Culture=neutral,PublicKeyToken=c5687fc88969c44d' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'MysqL.Data,PublicKeyToken=c5687fc88969c44d'
   at System.RuntimeTypeHandle.GetTypeByName(String name,Boolean throwOnError,Boolean ignoreCase,Boolean reflectionOnly,StackCrawlMarkHandle stackMark,IntPtr pPrivHostBinder,Boolean loadTypeFromPartialName,ObjectHandleOnStack type)
   at System.RuntimeTypeHandle.GetTypeByName(String name,StackCrawlMark& stackMark,Boolean loadTypeFromPartialName)
   at System.RuntimeType.GetType(String typeName,StackCrawlMark& stackMark)
   at System.Type.GetType(String typeName)
   at System.Data.Common.DbProviderFactories.GetFactory(DataRow providerRow)
   at System.Data.Common.DbProviderFactories.GetFactory(String providerInvariantName)
   at System.Data.Entity.Infrastructure.DependencyResolution.DefaultProviderFactoryResolver.GetService(Type type,Object key,Func`3 handleFailedLookup)
   at System.Data.Entity.Infrastructure.DependencyResolution.DefaultProviderFactoryResolver.GetService(Type type,Object key)
   at System.Data.Entity.Infrastructure.DependencyResolution.CachingDependencyResolver.<>c__DisplayClass1.MysqL.Data,PublicKeyToken=c5687fc88969c44d' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
最佳答案
在你的web.config中:

MysqL.Data.MysqLClient" />
  MysqL Data Provider" invariant="MysqL.Data.MysqLClient" description=".Net Framework Data Provider for MysqL" type="MysqL.Data.MysqLClient.MysqLClientFactory,MysqL.Data,PublicKeyToken=c5687fc88969c44d" />

版本设置为6.9.3.0但在bin文件文件MysqL.Data.dll和MysqL.Data.Entity.EF6.dll的版本为6.8.3.0

修改您的Web配置以使用正确的版本或从packages文件夹更新您的dll.

您的问题的根源是,当您使用nuget安装MysqL.Data.Entities时,它将旧版本的MysqL.Data替换为较新版本,但Web配置保持不变.

原文链接:https://www.f2er.com/mysql/433801.html

猜你在找的MySQL相关文章