public ActionResult Index(){var employees = db.Employees.Include(e => e.Departments);return View(employees.ToList());}
控制器自动生成的这个方法,为什么最后返回的时候要 ToList()?
看你的View绑定的如果是 IEmumerable<模型类> 或者 List<模型类>,那么 ToList 才能满足类型的兼容