title: LINQ to Entities only supports casting Entity Data Model primitive types?
body: <p>I'm trying to populate a dropdown in my view. Any help is greatly appreciated. Thanks.</p>
  <p>Error:</p>
  <blockquote>
  <p>Unable to cast the type 'System.Int32' to type 'System.Object'.</p>
  <p>LINQ to Entities only supports casting Entity Data Model primitive types.</p>
  </blockquote>
  <p>Controller:</p>
  <pre><code>ViewBag.category = (from c in new IntraEntities().CategoryItems
                     select new SelectListItem() {Text=c.Name, Value=&quot;&quot;+c.ID }).ToList&lt;SelectListItem&gt;();
  </code></pre>
  <p>View:</p>
  <pre><code>Category:&lt;br /&gt;@Html.DropDownList(&quot;category&quot;, (List&lt;SelectListItem&gt;)ViewBag.category)
  </code></pre>