脚手架控制器抛出的调用目标已引发异常

编程入门 行业动态 更新时间:2024-10-23 05:40:04
本文介绍了脚手架控制器抛出的调用目标已引发异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我创建了一个单独的类库项目来存储数据库上下文和模型类. 在同一解决方案中,我创建了一个ASP.NET MVC项目,并引用了类库项目,并在项目的Web.config文件中包括了数据库上下文的连接字符串.

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.

但是,当我尝试添加控制器(使用EF使用视图)时,出现以下错误:

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.

推荐答案

我定义了多个ConnectionString.我从我的类库中删除了默认值,并将其替换为ConstringStrings.现在工作正常!

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

更多推荐

脚手架控制器抛出的调用目标已引发异常

本文发布于:2023-11-17 00:04:20,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1608066.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:脚手架   抛出   控制器   异常   目标

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!