c# - 应用程序不能搭建项目

标签 c# sql asp.net-mvc entity-framework-6 asp.net-mvc-scaffolding

我在 VS 2013 Professional 中创建了一个 MVC 5 应用程序,然后首先将 EF 6.1 代码与 SQL Server Express 上的现有数据库结合使用。当我尝试创建 View 时,我使用“New scaffolded item...”然后选择“MVC 5 controller with views, using Entity Framework”。我选择模型和上下文类并单击确定。然后出现以下错误消息,并且没有创建代码。我已经卸载了 EF Power Tools 并出现同样的错误。

错误

There was an error running the selected code generator: ‘Exception has been thrown by the target of an invocation.’

我还尝试过卸载/重新安装 VS 2013 和 SQL Server,但不做任何更改。

关于可能导致此错误的原因还有其他想法吗?

最佳答案

在我的例子中,我将我的连接字符串从 Web.config 移到了

<connectionStrings configSource="ConnectionStrings.config"/>

当我尝试构建脚手架时开始出现错误。

There was an error running the selected code generator: ‘Exception has been thrown by the target of an invocation.’

将我的连接字符串移回 Web.config 解决了我的问题。

关于c# - 应用程序不能搭建项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23576294/

相关文章:

asp.net-mvc - 命名空间更改 - 发现多个类型与名为 'Home' 的 Controller 匹配

c# - Dictionary<Tkey, TValue>, List<T> 和其他集合实现/运行时

c# - 从图像动态创建 XNA Sprite

c# - 提交按钮在 asp.net mvc 中不起作用

c# - 从 ???_GetDisplayData 和 GROUP 数据中按天选择 DataTable(只有一些值),其中组规则对于不同的列是不同的

sql - 没有特定子记录的父记录的 Rails 范围

c# - 使用 Dynamic Linq 和 EPPlus 导出到 Excel?

c# - 自定义 icomparer 错误 - 无法从用法中推断出类型参数

c# - .NET 抛出 WebException 而不是设置 StatusCode

sql - 为数据组选择 DISTINCT