繁体   English   中英

EntityFramework 错误:提供程序未返回 ProviderManifest 实例

[英]EntityFramework error: The provider did not return a ProviderManifest instance

我的项目在 C# 中使用 ASP.NET MVC4 和 Visual Studio 2012 for Web Express。

编译我的项目时,出现以下错误:

提供程序未返回 ProviderManifest 实例。 无法确定存储版本; 需要有效的存储连接或版本提示。

经过数小时的搜索,我认为错误与实体框架有关。 我还在这里找到了解决此错误的方法: http ://forums.devart.com/viewtopic.php?f=32&t=25748

解决方法建议我将.edmx文件中的ProviderManifestToken="2012"字段更改为ProviderManifestToken="2008"

这样做之后,错误就消失了。 但是当我运行项目时,我遇到了另一个问题,运行时错误:

无法加载文件或程序集“Microsoft.Data.Edm”或其依赖项之一。 找到的程序集的清单定义与程序集引用不匹配。 (来自 HRESULT 的异常:0x80131040)

=== 预绑定状态信息 ===
日志:DisplayName = Microsoft.Data.Edm
(部分的)
警告:为程序集提供了部分绑定信息:
警告:程序集名称:Microsoft.Data.Edm | 域 ID:2
警告:仅提供部分程序集显示名称时会发生部分绑定。
警告:这可能会导致活页夹加载不正确的程序集。
警告:建议为程序集提供完全指定的文本标识,
WRN:由简单的名称、版本、文化和公钥标记组成。
警告:有关此问题的详细信息和常见解决方案,请参阅白皮书http://go.microsoft.com/fwlink/?LinkId=109270
日志:Appbase = file:///C:/Users/Pedro/Documents/Visual Studio 2012/Projects/Dockis/D​​evelopment/Dockis/D​​ockis/
日志:初始 PrivatePath = C:\\Users\\Pedro\\Documents\\Visual Studio 2012\\Projects\\Dockis\\Development\\Dockis\\Dockis\\bin
调用程序集:(未知)。

LOG:此绑定在默认加载上下文中开始。
日志:使用应用程序配置文件:C:\\Users\\Pedro\\Documents\\Visual Studio 2012\\Projects\\Dockis\\Development\\Dockis\\Dockis\\web.config
LOG:使用主机配置文件:C:\\Users\\Pedro\\Documents\\IISExpress\\config\\aspnet.config
LOG:使用 C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\config\\machine.config 中的机器配置文件。

LOG:此时未将策略应用于引用(私有、自定义、部分或基于位置的程序集绑定)。
日志:正在尝试下载新的 URL 文件:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/vs/78aa89a1/af9f01eb/Microsoft.Data.Edm.DLL。
日志:尝试下载新 URL 文件:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/vs/78aa89a1/af9f01eb/Microsoft.Data.Edm/Microsoft.Data.Edm .DLL。
日志:正在尝试下载新的 URL 文件:///C:/Users/Pedro/Documents/Visual Studio 2012/Projects/Dockis/D​​evelopment/Dockis/D​​ockis/bin/Microsoft.Data.Edm.DLL。
日志:使用应用程序配置文件:C:\\Users\\Pedro\\Documents\\Visual Studio 2012\\Projects\\Dockis\\Development\\Dockis\\Dockis\\web.config
LOG:使用主机配置文件:C:\\Users\\Pedro\\Documents\\IISExpress\\config\\aspnet.config
LOG:使用 C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\config\\machine.config 中的机器配置文件。
LOG:在应用程序配置文件中找到重定向:5.6.0.0 重定向到 5.6.1.0。
日志:政策后参考:Microsoft.Data.Edm,版本=5.6.1.0,文化=中性,PublicKeyToken=31bf3856ad364e35
日志:正在尝试下载新的 URL 文件:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/vs/78aa89a1/af9f01eb/Microsoft.Data.Edm.DLL。
日志:尝试下载新 URL 文件:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/vs/78aa89a1/af9f01eb/Microsoft.Data.Edm/Microsoft.Data.Edm .DLL。
日志:正在尝试下载新的 URL 文件:///C:/Users/Pedro/Documents/Visual Studio 2012/Projects/Dockis/D​​evelopment/Dockis/D​​ockis/bin/Microsoft.Data.Edm.DLL。
警告:比较程序集名称导致不匹配:内部版本号
ERR:无法完成程序集的设置(hr = 0x80131040)。 探测终止。

堆栈跟踪:

[FileLoadException: Could not load file or assembly 'Microsoft.Data.Edm' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]

[FileLoadException: Could not load file or assembly 'Microsoft.Data.Edm, Version=5.6.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
   System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
   System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +34
   System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +152
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +77
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +16
   System.Reflection.Assembly.Load(String assemblyString) +28
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +38

[ConfigurationErrorsException: Could not load file or assembly 'Microsoft.Data.Edm, Version=5.6.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +752
   System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +218
   System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +130
   System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +170
   System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +91
   System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +285
   System.Web.Compilation.BuildManager.ExecutePreAppStart() +153
   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +521

[HttpException (0x80004005): Could not load file or assembly 'Microsoft.Data.Edm, Version=5.6.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9950728
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254

Dockis 是项目的名称。 在看到这个错误后,我花了几个小时相信错误存在于正在使用的包的版本中。 但是,情况似乎并非如此,因为大多数软件包都是最新的,并且它们之间似乎没有任何冲突。

因此,我重新相信问题出在 EntityFramework 的版本上,但我不知道如何解决这个问题。

我全神贯注,如果您有任何建议,我将不胜感激。

下载http://www.microsoft.com/en-us/download/details.aspx?id=40762并将Nuget EF更新到6.1.3,一切都会正常工作。

显然,问题是我正在使用的Visual Studio版本。 如果你问我,请大笑。 删除Visual Studio Web Express 2012并安装Visual Studio 2013 Ultimate后,一切都开始正常工作。

在.edmx文件中的ProviderManifestToken="2012"中替换2012和2008,对我来说很有用。

  1. ProviderManifestToken="2012"中将2012替换为2008
  2. 保存.edmx文件
  3. 清洁和重建解决方案

这对我有用,而不会在.edmx文件中将ProviderManifestToken =“2012”更改为2008。

在.edmx文件中,我将以下值从True更改为False。

<edmx:DesignerProperty Name="UseLegacyProvider" Value="False" /> 

“提供程序未返回ProviderManifest实例。” 错误消失了。

发生这种情况是因为VS2012不支持sql 2012及更高版本。 将ProviderManifestToken的值更改为2008

不确定它是否是Visual Studio问题。 或者只是实体框架无法正确识别提供者清单。 我通过编辑edmx文件并在<Schema ProviderManifestToken="2008" ...>中将2012替换为2008来消除错误<Schema ProviderManifestToken="2008" ...>

  1. 转到项目所在的位置(打开解决方案资源管理器。右键单击解决方案,然后单击“在文件资源管理器中打开文件夹”
  2. 用记事本打开EDMX文件,将ProviderManifestToken =“2012”更改为ProviderManifestToken =“2008”。 保存

  3. 建立你的解决方案

对我来说,这是因为当我使用TeamCity来破坏我的网站时,它改变了web.config文件。

它删除了connectionString并将debug = true添加到System.Web编译中

<system.web>
    <customErrors mode="Off" />
    <authentication mode="None" />
    <compilation debug="true" targetFramework="4.5.2" />
    <httpRuntime targetFramework="4.5.2" maxRequestLength="1048576" />
    <httpModules>
      <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" />
    </httpModules>
  </system.web>

我manuel修复了web.config文件,它现在又适用于我。

我实际上得到了这个错误,因为我在用户设置 xml 文件中有一个不正确的设置。 我已从应用程序属性中删除了它们,但它们仍在设置文件中,并且引发了异常。 显然,它使用了与 db 相同的类,因此似乎引发了 db 错误。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM