Reputation: 135
I am trying to create a webapi controller, within a site. it is a template controller, nothing changed from what visual studio has inserted.
The code is within an MVC4 site, which runs completely without any errors, however, when I call webapi controller, I am receiving this error:
Could not load file or assembly 'EntityFramework, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified.
I have uninstalled EntityFramework nuget package, and when I search in entire solution, it is not found in any file, however, I am repeatedly receiving this error.
Any clues what might be a possible solution to this?
Upvotes: 3
Views: 3159
Reputation: 1
In my case, since I was using .NET 4.0 I had to revert back to EntityFramework 4.1 after my uprade to VS2012 (needed for a different project).
Running in the Package Manager Console in VS 2010 this command:
PM> Install-Package EntityFramework -Version 4.1.10715.0
Upvotes: 0
Reputation: 1637
Removing the web.config dependentAssembly lines for EntityFramework fixed it for my project.
Upvotes: 0
Reputation: 6983
Try opening the .csproj
file for your project in a text editor such as Notepad and searching for the phrase "EntityFramework". If it turns up hits, that may give you a clue as to what that problem is.
Upvotes: 0
Reputation: 42276
Try deleting the obj
and bin
folders for each project then rebuilding the application. This has helped me fix the same problem on more than one occasion.
Upvotes: 0
Reputation: 1901
it is a template controller, nothing changed from what visual studio has inserted.
Entity Framework might be a dependency because of these templates. Some of the templates will generate DataControllers
, which require EF. If you read carefully, you will see in the text displayed by the template: "Generate ...., using Entity Framework"
If that is not the case, and you have simple ApiControllers
, and you've uninstalled EF, double-check your packages.config
file, to make sure that there is no reference to Entity Framework there either.
Upvotes: 0
Reputation: 8190
Try adding the following to your web.config file:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" />
<bindingRedirect oldVersion="0.0.0.0-4.3.1.0" newVersion="4.3.1.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
Upvotes: 1
Reputation: 111
I had the same problem.
All things were working and then just started to give a 404 for all web api requests.
I have tried everything .. the only thing that resolved my issue was to add a reference of EF 4.1.0.0 to my project and also to add it to Web.config.
It strange because nowhere in my solution im using or referencing EF.
I didnt have 4.1 version and I downloaded it from here http://www.microsoft.com/en-us/download/details.aspx?id=26825
I found why EF 4.1 is listed as dependency. The error came only when i wanted to publish the site. And what i did is only to Add Deployable Dependecies and check ASP.NET MVC, because the host server didn't have MVC 4 installed. When i looked on _bin_deployableAssemblies folder
my eye caught System.Web.Http.Data.EntityFramework.dll and immediately i decompiled and voila i found EF 4.1 referenced there.
Upvotes: 2
Reputation: 8592
Arian, I see that error every time I do something with the stock VS template when using EF4.
Turn it around and install Entity Framework again in the solution. Launch the Nuget manager or do it from its console:
Install-Package EntityFramework
(for 4.3.1)
Install-Package EntityFramework -Pre
(for 5.0.0rc)
Once you have the DLL in your references (btw, check that), the error goes away
Upvotes: 1