17

My project is using ASP.NET MVC4, in C# with Visual Studio 2012 for Web Express.

When compiling my project, I have the following error:

The provider did not return a ProviderManifest instance. Could not determine storage version; a valid storage connection or a version hint is required.

After many hours of search I believe that is error is somehow related to Entity Framework. I also found a work around for this error here: http://forums.devart.com/viewtopic.php?f=32&t=25748

The workaround suggests that I change the field ProviderManifestToken="2012" to ProviderManifestToken="2008" in my .edmx file.

After doing that the error goes away. But then I have another problem when I run the project, a runtime error:

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)

=== Pre-bind state information ===
LOG: DisplayName = Microsoft.Data.Edm
(Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: Microsoft.Data.Edm | Domain ID: 2
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///C:/Users/Pedro/Documents/Visual Studio 2012/Projects/Dockis/Development/Dockis/Dockis/
LOG: Initial PrivatePath = C:\Users\Pedro\Documents\Visual Studio 2012\Projects\Dockis\Development\Dockis\Dockis\bin
Calling assembly : (Unknown).

LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\Pedro\Documents\Visual Studio 2012\Projects\Dockis\Development\Dockis\Dockis\web.config
LOG: Using host configuration file: C:\Users\Pedro\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.

LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/vs/78aa89a1/af9f01eb/Microsoft.Data.Edm.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/vs/78aa89a1/af9f01eb/Microsoft.Data.Edm/Microsoft.Data.Edm.DLL.
LOG: Attempting download of new URL file:///C:/Users/Pedro/Documents/Visual Studio 2012/Projects/Dockis/Development/Dockis/Dockis/bin/Microsoft.Data.Edm.DLL.
LOG: Using application configuration file: C:\Users\Pedro\Documents\Visual Studio 2012\Projects\Dockis\Development\Dockis\Dockis\web.config
LOG: Using host configuration file: C:\Users\Pedro\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Redirect found in application configuration file: 5.6.0.0 redirected to 5.6.1.0.
LOG: Post-policy reference: Microsoft.Data.Edm, Version=5.6.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/vs/78aa89a1/af9f01eb/Microsoft.Data.Edm.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/vs/78aa89a1/af9f01eb/Microsoft.Data.Edm/Microsoft.Data.Edm.DLL.
LOG: Attempting download of new URL file:///C:/Users/Pedro/Documents/Visual Studio 2012/Projects/Dockis/Development/Dockis/Dockis/bin/Microsoft.Data.Edm.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Build Number
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

Stack Trace:

[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 is the name of the project. After seeing this error I spent several hours believing that the errors lied somewhere in the versions of the package being used. However, this does not seem to be the case, since the majority of packages are up to date and there doesn't seem to be any conflicts between them.

Consequently, I am back to believing that the problem lies with the version of EntityFramework, but I am out of ideas on how to fix this.

I'm all ears, if you have any suggestions, I'll appreciate them.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Flame_Phoenix
  • 16,489
  • 37
  • 131
  • 266

9 Answers9

16

Download http://www.microsoft.com/en-us/download/details.aspx?id=40762 and update Nuget EF to 6.1.3 and everything will work just fine.

Khalil Khalaf
  • 9,259
  • 11
  • 62
  • 104
suhyura
  • 188
  • 1
  • 6
7

Aparently, the problem was the Visual studio version that I was using. Mind blowing if you ask me. After removing Visual Studio Web Express 2012 and installing Visual Studio 2013 Ultimate everything started working as it should.

Flame_Phoenix
  • 16,489
  • 37
  • 131
  • 266
  • 1
    I had the same issue. VS2012 Premium had the error. VS2013 Premium built it ok. Reopened it in VS2012, and it failed again. No idea. Weird. – granadaCoder Jan 15 '15 at 19:09
5

Replacing 2012 with 2008 in ProviderManifestToken="2012" in the .edmx file worked for me.

  1. Replace 2012 with 2008 in ProviderManifestToken="2012"
  2. Save the .edmx file
  3. Clean and rebuild solution
fenceop
  • 1,439
  • 3
  • 18
  • 29
Kapil Rattan
  • 51
  • 1
  • 1
4

This worked for me without changing the ProviderManifestToken="2012" to 2008 in the .edmx file.

in the .edmx file, I changed the following value from True to False.

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

The "The provider did not return a ProviderManifest instance." error went away.

Tunaki
  • 132,869
  • 46
  • 340
  • 423
  • This is a much better response than the ones suggesting that ProviderManifestToken attribute value is changed from 2012 to 2008. Using 2008 prevents the Entity Framework from using SQL 2012-specific functionality, such as OFFSET and FETCH. – Pando Jan 25 '18 at 22:58
  • Not worked for me, I have "False" value in that property and the error message still appear. – dancerjude Jan 30 '19 at 12:07
2

This happens because VS2012 does not support sql 2012 and above. Change the value of ProviderManifestToken to 2008

1

Not sure if it is a Visual studio problem. Or just entity framework unable to recognize the provider manifest correctly. I got rid of the error by editing the edmx file and replacing 2012 with 2008 in the <Schema ProviderManifestToken="2008" ...>

0
  1. go where you project is located(open Solution explorer. right click on solution and click on "Open Folder in file explorer"
  2. open EDMX file with notepad and change ProviderManifestToken="2012" to ProviderManifestToken="2008". save it

  3. build your solution

Ghasem
  • 14,455
  • 21
  • 138
  • 171
0

For me it was because when I used TeamCity to deply my site, it changed the web.config file.

It removed the connectionString and added debug=true to System.Web compilation

<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>

I manuel fixed the web.config file, and it now works for me again.

0

I actually got this error because I had an incorrect setting in the user settings xml file. I had deleted them from the app properties but they were still in the settings file and it threw an exception. Evidently it uses the same class the db does so appeared to throw a db error.

John Lord
  • 1,941
  • 12
  • 27