An exception was thrown at the call of the controller when the controller created the forest.

I created a separate class library project to store database context classes and models. In the same solution, I created an ASP.NET MVC project and referenced the class library project, and also included a connection string for the database context in the Web.config project file.

However, when I try to add a controller (with views using EF), I get the following error:

An exception is thrown by the call target.

I can see the database and model context classes in the Add Controller drop-down lists, so I don't think this is a link problem.

If someone is also experiencing this error (with this configuration), your help will be greatly appreciated.

+7
asp.net-mvc entity-framework dbcontext
source share
2 answers

I had several definitions of ConnectionStrings. I removed the default value and replaced it with ConstringStrings from my class library. Works great!

Solution taken from the following message: Application cannot create forest items

0
source share

I had the same problem too. In my case, the "web.config" of the web project did not have a "section" element for the "entityFramework" inside the "configSections" Just added this and it worked.

-one
source share

All Articles