title: foreach GetEnumerator error when converting to Razor syntax
body: <p>I'm currently in the process of converting the MVC 2 portion of a hybrid Web Forms/MVC 2 application to MVC 3 (I'm not familiar with Web Forms or MVC 2) and have been encountering some problems with some of the foreach statements (which work fine in the original hybrid application).</p>
  
  <p>When converting to Razor, some (not all) of my foreach statements will say something along the lines of: </p>
  
  <blockquote>
    <p>foreach statement cannot operate on variables of type
    'System.Data.Objects.DataClasses.EntityCollection&lt;Project.Activity.PortalMember&gt;'
    because
    'System.Data.Objects.DataClasses.EntityCollection&lt;Project.Activity.PortalMember&gt;'
    does not contain a public definition for 'GetEnumerator'</p>
  </blockquote>
  
  <p>This is an example .ascx from the Web Forms/MVC 2 application where the foreach works fine:</p>
  
  <pre><code>&lt;%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl&lt;Project.Activity.PortalGroup&gt;" %&gt;
  &lt;% if (Model.PortalMembers.Count() &gt; 0) {  %&gt;
      &lt;div&gt;
      &lt;% foreach (var item in Model.PortalMembers) {  %&gt;
          &lt;div&gt;
              &lt;%: item.SubAccount.FirstName %&gt; &lt;%: item.SubAccount.LastName %&gt;
          &lt;/div&gt;
      &lt;%} %&gt;
      &lt;/div&gt;
  &lt;%} %&gt;
  </code></pre>
  
  <p>This is my attempt for the .cshtml conversion that is giving me the error:</p>
  
  <pre><code>@model Project.Activity.PortalGroup
  
  @if (Model.PortalMembers.Count() &gt; 0) 
  {
      &lt;div&gt;
      @foreach (var item in Model.PortalMembers) 
      {
          &lt;div&gt;
              @item.SubAccount.FirstName @item.SubAccount.LastName
          &lt;/div&gt;
      }
      &lt;/div&gt;
  }
  </code></pre>