Could not load file or assembly 'EntityFramework' error

Go To StackoverFlow.com

8

Could not load file or assembly 'EntityFramework, Version=4.3.1.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

I only get this error when I add this code into my project:

private IUserRepository repository;

        public SearchController(IUserRepository repo)
        {
            repository = repo;
        }

I suppose that makes sense as I'm using EntityFramework for this. I'm just now sure how to fix this bug.

I've looked at this link: http://msdn.microsoft.com/en-us/library/e74a18c4.aspx Though I'm not sure how to use this program? (It's always blank).

I think that this bug may have something to do with the fact that my database is hosted by dotnet-host.com and that there's some local references that break when it interacts with the database online.

2012-04-03 22:21
by Hanna
This is where I found my answer - http://stackoverflow.com/questions/9540168/error-loading-entityframework-4-3-1 check all your dlls make sure they have the same re - Micah Armantrout 2012-04-05 19:06


18

What the error is telling you is that your project referenced a different version of EntityFramework.dll than it found at runtime.

Check which version of EntityFramework.dll did you reference in your project (update your question).

Make sure you copy all the relevant dll and *.manifest into application's bin folder.

Since It's an external host, You might need to install the EntityFramework through WebMatrix Package Manager. If you do, you can follow this tutorial.

  1. Just make sure to install the same version of EntityFramework on your host site that you use for development, or
  2. change your assembly reference to Specific Version = false on EntityFramework dlls (Note I'm not sure if it will work, because I always try to develop and deploy using the same versions, so maybe somebody can confirm?).
2012-04-03 22:32
by surfen
This is what the issue was. For some reason (by default) it uses a lower version number than when I manually reference it, and since I was referencing it in two projects (one by default, once manually) it was causing a version number inconsistency. Thank you - Hanna 2012-04-06 23:39
I had this issue after I had added a new MVC project to a sln with multiple other projects referencing EntityFramework (6.0.0.0). The web.config for my new MVC project was trying to reference 5.0.0.0. Changed to 6.0.0.0 and everyone happ - SleepyBoBos 2015-06-11 05:15