title: How to get list of records using entity framework error -The model item passed into the dictionary , but this dictionary requires a model item
body: <p>how to get the list of records in the table using entity framework , im getting error -</p>
  
  <blockquote>
    <p>The model item passed into the dictionary is of type
    'System.Data.Entity.DbSet<code>1[SmartPondDataAccess.Alert]', but this
    dictionary requires a model item of type
    'System.Collections.Generic.IEnumerable</code>1[SmartPondDataAccess.AlertsViewModel]'.</p>
  </blockquote>
  
  <p>view model</p>
  
  <pre><code>   public class AlertsViewModel
      {
          public int Deviceid { get; set; }
          public Nullable&lt;decimal&gt; LowDO1 { get; set; }
          public Nullable&lt;decimal&gt; LowDO2 { get; set; }
  
      }
  </code></pre>
  
  <p>c# code</p>
  
  <pre><code>public ActionResult Settings() {
  
              smartpondEntities entities = new smartpondEntities();
              return View(entities.Alerts);
          }
  </code></pre>
  
  <p>view</p>
  
  <pre><code>@model IEnumerable&lt;SmartPondDataAccess.AlertsViewModel&gt;
  @{
      ViewBag.Title = "Settings";
      Layout = "~/Views/Shared/_Layout_SmartPond.cshtml";
  }
  
  
  &lt;table id="tblCustomers" class="table" cellpadding="0" cellspacing="0"&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th style="width:150px"&gt;Name&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          @foreach (var item in Model)
          {
              &lt;tr&gt;
                  &lt;td&gt;@item.Deviceid &lt;/td&gt;
              &lt;/tr&gt;
          }
      &lt;/tbody&gt;
  
  &lt;/table&gt;
  </code></pre>