Exception has been thrown by the target of an invocation thrown when scaffolding a controller

asp.net-mvc dbcontext entity-framework scaffold

Question

I created a separate Class Library project to store the Database Context and Model Classes. In the same solution, I created an ASP.NET MVC project and referenced the Class Library project, as well as include the Connection String for the Database Context, in the project's Web.config file.

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

Exception has been thrown by the target of an invocation.

I am able to see the Database Context and Model Classes in the Add Controller drop down boxes, so I don't think its a referencing issue.

If anyone is also experiencing this error (with this configuration), you assistance will be greatly appreciated.

1
10
1/5/2015 9:26:21 AM

Accepted Answer

I had more than one ConnectionStrings define. I removed the default and replaced it with the ConstringStrings from my Class Library. Works fine now!

Solution taken from the following post: Application can't scaffold items

3
9/17/2017 12:20:29 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow