Per @David-Tansey (from this answer - see for a much more detailed explanation):
(changed to suit this question):
When you use
@Html.EditorFor(c => c.Employees)
MVC convention chooses the default template forIEnumerable
. This template is part of the MVC framework, and what it does is generateHtml.EditorFor()
for each item in the enumeration. That template then generates the appropriate editor template for each item in the list individually - in your case they're all instances of Employee, so, the Employee template is used for each item.
To sum up his explanation on when you use the named template, you are, in effect, passing the entire IEnumerable<Employee>
to a template expecting a single Employee
by using @Html.EditorFor(company => company.Employees, "EmployeeEditorTemplate")
.
note: I really only answered this because it had no answer and I stumbled here first. At least now someone doesn't close it and potentially miss an answer without having to go through the rigmarole of getting duplicate question votes, blah blah.