title: model item passed into the dictionary is of type PagedList.PagedList[] but this dictionary requires a model item of type
body: <p>Im trying to use view models in my project but I have this error:</p>
  
  <blockquote>
    <p>The model item passed into the dictionary is of type
    'PagedList.PagedList<code>1[ContosoUniversity.Models.Course]', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable</code>1[ContosoUniversity.ViewModels.CourseViewModel]'.</p>
  </blockquote>
  
  <p>Controller:</p>
  
  <pre><code>public ActionResult Index(int? page)
      {
          int pageNumber = page ?? 1;
  
          var courses = courseService.GetAll();
  
          var coursesViewList = Mapper.Map&lt;IEnumerable&lt;Course&gt;, IEnumerable&lt;CourseViewModel&gt;&gt;(courses);
  
          var model = coursesViewList.ToPagedList(pageNumber, PageSize);
  
          return View(model);
      }
  </code></pre>
  
  <p>View:</p>
  
  <pre><code>@model IEnumerable&lt;ContosoUniversity.ViewModels.CourseViewModel&gt;
  @using PagedList.Mvc;
  @using PagedList;
  
  
  @{
      ViewBag.Title = "Index";
  }
  
  &lt;h2&gt;Index&lt;/h2&gt;
  
  &lt;p&gt;
      @Html.ActionLink("Create New", "Create")
  &lt;/p&gt;
  
  &lt;table class="table"&gt;
      &lt;tr&gt;
          &lt;th&gt;
              @Html.DisplayNameFor(model =&gt; model.Title)
          &lt;/th&gt;
          &lt;th&gt;
              @Html.DisplayNameFor(model =&gt; model.Credits)
          &lt;/th&gt;
          &lt;th&gt;
              Students
          &lt;/th&gt;
          &lt;th&gt;&lt;/th&gt;
      &lt;/tr&gt;
  
  @foreach (var item in Model) {
      &lt;tr&gt;
          &lt;td&gt;
              @Html.DisplayFor(modelItem =&gt; item.Title)
          &lt;/td&gt;
          &lt;td&gt;
              @Html.DisplayFor(modelItem =&gt; item.Credits)
          &lt;/td&gt;
          &lt;td&gt;
              @string.Join(",", item.Enrollments.Select(e =&gt; e.Student.FullName))
          &lt;/td&gt;
          &lt;td&gt;
              @Html.ActionLink("Edit", "Edit", new { id=item.CourseID }) |
              @Html.ActionLink("Delete", "Delete", new { id=item.CourseID })
          &lt;/td&gt;
      &lt;/tr&gt;
  }
  
  &lt;/table&gt;
  
  
  @Html.PagedListPager((IPagedList)Model, page =&gt; Url.Action("Index", new { page }))
  </code></pre>
  
  <p>Could somebody help me to resolve a problem please?</p>