title: Only parameterless constructors and initializers are supported in LINQ to Entities - MVC / C#
body: <p>I am changing my Linq-to-Sql application to EF 6.1, generate the ViewData using:</p>
  
  <pre><code>public IEnumerable&lt;KeyValuePair&lt;int, string&gt;&gt; GetOhaTypes ()
          {
          return (from type in db.OhaType
                  where type.Disabled == false
                  orderby type.Name
                  select new KeyValuePair&lt;int, string&gt;(type.OhaTypeId, type.Name));
          }
  </code></pre>
  
  <p>In Controller:</p>
  
  <pre><code>ViewData["OhaTypes"] = _vRepository.GetOhaTypes();
  </code></pre>
  
  <p>In the View:
  @functions{</p>
  
  <pre><code>    List&lt;SelectListItem&gt; GetDropDownListItems (string listName, int currentValue)
          {
          var list = new List&lt;SelectListItem&gt;();
          var pairs = this.ViewData[listName] as IEnumerable&lt;KeyValuePair&lt;int, string&gt;&gt;;
  
          if (pairs != null)
              {
              list.AddRange(pairs.Select(pair =&gt; new SelectListItem
              {
                  Text = pair.Value,
                  Value = pair.Key.ToString(CultureInfo.InvariantCulture),
                  Selected = pair.Key == currentValue
              }));
              }
          return list;
          }
  }
  </code></pre>
  
  <p>I get this error:</p>
  
  <pre><code>Only parameterless constructors and initializers are supported in LINQ to Entities
  </code></pre>
  
  <p>Would appreciate your suggestions.</p>