title: The model item passed into the dictionary is of type 'System.Data.Entity.DbSet
body: <p>I am learning MVC hence unable to figure out simpler stuff I believe. I am trying to keep both List and Create actions on the same View. As advised I created a ViewModel but it is throwing an error. I am sure there are some fixes required in my below code.</p>
  
  <blockquote>
    <p>The model item passed into the dictionary is of type 'System.Data.Entity.DbSet`1[Entity.EmployeeVM]', but this dictionary requires a model item of type 'Entity.EmployeeVM'. </p>
  </blockquote>
  
  <p>My Model Class</p>
  
  <pre><code>public class Employee
  {
      public int ID { get; set; }
  
      public string Name { get; set; }
  
  }
  </code></pre>
  
  <p>My View Model Class</p>
  
  <pre><code>public class EmployeeVM
  {
     public Employee Employee { get; set; }
     public List&lt;Employee&gt; Employees { get; set; }
  }
  </code></pre>
  
  <p>My Repository Interface and its implementation</p>
  
  <pre><code>public interface IRolesRepository
  {
      IQueryable&lt;EmployeeVM&gt; Employees { get; }
      void Save(EmployeeVM Employee);
  }
  
  public IQueryable&lt;Test&gt; Employees 
  {
      get { return context.Employees; }
  }
  
  Similar function for Saving
  </code></pre>
  
  <p>My Controller Class</p>
  
  <pre><code>public ViewResult Index()
  {
  
      return View(repository.Employees);
  }
  
  [HttpPost]
  public ActionResult Create(EmployeeVM employee, string Name)
  {
      employee.Employee.Name = Name;
  
      repository.Save(role);
  
      return RedirectToAction("Index");
  
  }
  </code></pre>
  
  <p>My View</p>
  
  <pre><code>@model ERP.Domain.Entity.EmployeeVM
  
  &lt;div class="jumbotron"&gt;
      @using (Html.BeginForm("Create", "MyController", FormMethod.Post))
      {
  
          &lt;label&gt;Name&lt;/label&gt;
          &lt;input id="txtName" type="text" name="Name" class="btn btn-default" /&gt;
  
  
          &lt;input type="submit" value="Save" class="btn btn-primary" /&gt;
      }
  &lt;/div&gt;
  &lt;div&gt;
      &lt;table class="table table-hover"&gt;
          &lt;tr&gt;
              &lt;th&gt;  
                Name
              &lt;/th&gt; 
          &lt;/tr&gt;
          @foreach (var item in Model.Roles)
          {
              &lt;tr&gt;
                  &lt;td&gt;@Html.ActionLink(item.Name, "Edit")
                  &lt;/td&gt;
  
              &lt;/tr&gt;
          }
      &lt;/table&gt;
  &lt;/div&gt;
  </code></pre>