title: MVC error - The model item passed into the dictionary is of type 'System.Collections.Generic.List`
body: <p>I can't figure out what's going on with this error:  </p>
  
  <blockquote>
    <p>The model item passed into the dictionary is of type 'System.Collections.Generic.List1[RepositoryExample.Employee]', but this dictionary requires a model item of type 'RepositoryExample.Models.IEmployeeManagerRepository'.`</p>
  </blockquote>
  
  <p>I get the error when I go to the Index view. I added the Index View from the controller but there is no code in it.  I'm using Linq to SQL.  </p>
  
  <pre><code>@model RepositoryExample.Models.IEmployeeManagerRepository
  
  @{
  ViewBag.Title = "Index";
  }
  
  &lt;h2&gt;Index&lt;/h2&gt;
  </code></pre>
  
  <p>This is my code:</p>
  
  <p><strong>EmployeeController.cs</strong></p>
  
  <pre><code>    // GET: /Employee/
      public ActionResult Index()
      {
          return View(_repository.ListEmployees());
      }
  </code></pre>
  
  <p><strong>LinqEmployeeManagerRepository.cs</strong></p>
  
  <pre><code>public class LinqEmployeeManagerRepository: RepositoryExample.Models.IEmployeeManagerRepository
  {
      private DeptDirectoryDataClassesDataContext _db = new DeptDirectoryDataClassesDataContext();
  
      public Employee GetEmployee(string UserName)
      {
          return (from e in _db.Employees where e.UserName == UserName select e).FirstOrDefault();
      }
  
      public IEnumerable&lt;Employee&gt; ListEmployees()
      {
          return _db.Employees.ToList();
      }
  
      public Employee CreateEmployee(Employee employeeToCreate)
      {
          _db.Employees.InsertOnSubmit(employeeToCreate);
          _db.SubmitChanges();
          return employeeToCreate; 
      }
  
      public Employee EditEmployee(Employee employeeToEdit)
      { 
          var OriginalEmployee = GetEmployee(employeeToEdit.UserName);
          _db.Employees.Attach(employeeToEdit, OriginalEmployee);
          _db.SubmitChanges();
          return employeeToEdit; 
      }
  
      public void DeleteEmployee(Employee employeeToDelete)
      {
          var OriginalEmployee = GetEmployee(employeeToDelete.UserName);
          _db.Employees.DeleteOnSubmit(OriginalEmployee);
          _db.SubmitChanges();     
      }
  }
  </code></pre>
  
  <p><strong>IEmployeeManagerRepository.cs</strong></p>
  
  <pre><code>namespace RepositoryExample.Models
  {
      public interface IEmployeeManagerRepository
      {
          Employee CreateEmployee(Employee employeeToCreate);
          void DeleteEmployee(Employee employeeToDelete);
          Employee EditEmployee(Employee employeeToUpdate);
          Employee GetEmployee(string UserName);
          IEnumerable&lt;Employee&gt; ListEmployees(); 
      }
  }
  </code></pre>
  
  <p>Any ideas what I'm doing wrong? I'm trying to follow the example on Repository pattern in this tutorial: <a href="http://www.asp.net/mvc/tutorials/iteration-4-make-the-application-loosely-coupled-cs" rel="nofollow noreferrer">http://www.asp.net/mvc/tutorials/iteration-4-make-the-application-loosely-coupled-cs</a>.</p>