Reputation: 10002
I recently added a MVC4 Web Application to my solution and gave it a reference to my Common class library. The Common class library contains the models and context (EF Code First).
When attempting to use Visual Studio's scaffolding feature to "Add Controller" to the MVC4 Application, I get the following error:
Unable to retrieve metadata for 'Common.Models.MyContext'. Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
I have found a lot of similar questions on stack overflow, but none of them address this specific error message for this specific scenario.
In my investigations, I found that if I remove all the added packages and third party dll's from the Common library, I am able to use the "Add Controller" function without error. This tells me that one of my packages or third party dll's is not where it needs to be (as indicated by the error message).
So my questions are these:
Upvotes: 0
Views: 2297
Reputation: 311
If you are using separates projects, check if EF has the same version number!
Upvotes: 0
Reputation: 12174
Make sure your web application project has ALL the required references from other projects. Just because your Common project has a dependency on a DLL doesn't mean that reference will be copied to your web project. You will have to add the dependant DLLs manually as references with Copy Local set to "true"
Upvotes: 3