问题描述
我想在我的ASP.NET MVC项目添加控制器。
I'm trying to add a controller in my ASP.NET MVC project.
我使用实体框架code首先(5.0),当我用鼠标右键单击的控制器的在我的项目文件夹并选择的添加控制器的:
I am using Entity Framework Code First (5.0), and when I right-click the Controllers folder in my project and selecting Add Controller:
选择与读取的 MVC控制器之后/写操作和视图,使用实体框架的和其他设置,我得到这个消息:
After selecting MVC controller with read/write actions and views, using Entity Framework and other settings, I get this message:
有一个错误发生{0}。尝试重建项目。
似乎是特殊的构造我加入的DbContext
引起的问题。注释掉的构造后,它的工作再回来,但是这条消息出现了:
Seems that the special constructor I added to the DbContext
caused the problem. After commenting out the constructor, it's working back again, however this message appeared:
反正我检查活动日志,发现关于这个问题,或者在发生时间表任何记录没有资料,你应该知道这是怎么一回事,请发表评论。
Anyway I checked the activity log and found no info regarding that issue or any record at the occurrence timeline, should you know what this is all about, please comment on.
推荐答案
似乎特殊的构造我加入的DbContext
引起的问题。注释掉的构造和重新编译后,它的再次合作了。
Seems that the special constructor I added to the DbContext
caused the problem. After commenting out the constructor and re-compiling, it's working back again.
也许我应该在包裹是在设计时跳过一个条件语句构造内容,同时注释出足以让我。
Perhaps I should wrap the constructor contents in a conditional statement that is skipped at design-time, meanwhile commenting-out is enough for me.
这篇关于不能在ASP.NET MVC项目中添加控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!