在我的mvc项目中,我想使用实体框架添加一个带有视图的控制器。我用这个教程http://www.asp.net/mvc/overview/getting-started/introduction/accessing-your-models-data-from-a-controller在添加控制器时出现c#mvc 5错误
我rebuilded我的项目很多,很多次这样做。我尝试了一些我在互联网上找到的解决方案,比如Adding A New MVC 5 Controller with Views Using Entity Framework Scaffolding Error ,或者重新安装我的nuget软件包,重新启动Visual Studio,检查我的conecctiong字符串(看起来好像是btw),添加新模型等。我不知道下一步该怎么做,这就是为什么我在问你求助。
我用:
- 的Visual Studio 2013在Windows 7
- 的.NET Framework 4.6.2
我的模型代码:
public class UserResModel
{
[Display(Name = "ReservationID")]
public int ReservationID { get; set; }
[Display(Name = "Class")]
public string ClassName { get; set; }
[Display(Name = "When")]
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}", ApplyFormatInEditMode = true)]
public DateTime ClassWhen { get; set; }
[Display(Name = "Cancel reservation")]
public bool CancelRes { get; set; }
}
您的模型是否有默认构造函数?你能展示模型代码吗? – mbrdev
你是什么意思?我使用代码编辑我的问题 – Lea
将您的web项目设置为启动项目 –