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

旧时模样 提交于 2019-12-06 20:20:18

问题


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:


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



来源:https://stackoverflow.com/questions/27771404/exception-has-been-thrown-by-the-target-of-an-invocation-thrown-when-scaffolding

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!