这是我的控制器。我有一个列表格式的视图,但它给出了错误:
无法将类型'System.Collections.Generic.List'隐式转换为'MvcDemo.Models.Employee'G:\ MvcApp \ MvcDemo \ MvcDemo \ Controllers \ EmployeeController.cs 18
public ActionResult Details()
{
EmployeeContext ec = new EmployeeContext();
Employee e1 = ec.employee.ToList();
return View(e1);
}
我该如何解决这个问题?
答案 0 :(得分:2)
将其更改为如下。
public ActionResult Details()
{
EmployeeContext ec = new EmployeeContext();
List<Employee> e1 = ec.employee.ToList();
return View(e1);
}