如何将控制器添加到ASP.NET MVC与Visual Studio 2013和Entity Framework? [英] How do I add a controller to ASP.NET MVC with Visual Studio 2013 and Entity Framework?

查看:1008
本文介绍了如何将控制器添加到ASP.NET MVC与Visual Studio 2013和Entity Framework?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在Visual Studio 2013中添加控制器ASP.NET MVC 5.0和Entity Framework 6.0,我得到一个错误。我已经增加了一些控制器和生成的意见,但之后,我添加了数据表包,我得到这种类型的错误:

I am getting an error when I add a controller in Visual Studio 2013 with ASP.NET MVC 5.0 and Entity Framework 6.0. I have already added a few controllers and generated views but after I added the datatables package, I am getting this type of error:

Error 

"There was an error running the selected code generator"

"There was an error getting the type 'project.classes.StudentClass' Try rebuilding the project"

我已经清理和重建项目,但它仍然是行不通的。有一个名为 StudentClass 表,我想补充的控制器使用实体框架的表。我怎样才能成功生成控制器?

I have cleaned and rebuilt the project but it still isn't working. There is a table named StudentClass and I want to add the controller for that Table using Entity Framework. How can I generate the controller successfully?

推荐答案

如果你得到,说:有一个错误获取类型...,请确保您构建的Visual Studio项目您添加后的错误消息班上。脚手架使用反射来查找类。

If you get an error message that says "There was an error getting the type...", make sure that you built the Visual Studio project after you added the class. The scaffolding uses reflection to find the class.

这篇关于如何将控制器添加到ASP.NET MVC与Visual Studio 2013和Entity Framework?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆