title: MVC Core 1.0 NullReferenceException: Object reference not set to an instance of an object
body: <p>My code is trying to enumerate over a (currently empty) list of movies. When it gets to the <code>ForEach</code> loop it blows up with the stated error. </p>
  
  <p>I would think it would just not iterate (moveNext()). How can I fix this behavior so that it will just display an empty list when the collection is blank</p>
  
  <pre><code>@using System.Collections.Generic
  @using Microsoft.EntityFrameworkCore.Metadata.Internal
  @using x.Models
  @model IEnumerable&lt;x.Models.Movie&gt;
  
  @{
      ViewData["Title"] = "MovieView";
  }
  
  &lt;h2&gt;MovieView&lt;/h2&gt;
  
  &lt;p&gt;
      &lt;a asp-action="List"&gt;Movie List&lt;/a&gt;
  &lt;/p&gt;
  &lt;table class="table"&gt;
      &lt;thead&gt;
      &lt;tr&gt;
          &lt;th&gt;
              @Html.DisplayNameFor(model =&gt; model.Title)
          &lt;/th&gt;
          &lt;th&gt;
              @Html.DisplayNameFor(model =&gt; model.Description)
          &lt;/th&gt;
          &lt;th&gt;
              @Html.DisplayNameFor(model =&gt; model.Genre)
          &lt;/th&gt;
          &lt;th&gt;
              @Html.DisplayNameFor(model =&gt; model.Year)
          &lt;/th&gt;
          &lt;th&gt;&lt;/th&gt;
      &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          @foreach (Movie 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.Description)
                  &lt;/td&gt;
                  &lt;td&gt;
                      @Html.DisplayFor(modelItem =&gt; item.Genre)
                  &lt;/td&gt;
  
                  &lt;td&gt;
                      @Html.DisplayFor(modelItem =&gt; item.Year)
                  &lt;/td&gt;
                  &lt;td&gt;
                      &lt;a asp-action="Edit" asp-route-id="@item.Id"&gt;Edit&lt;/a&gt; |
                      &lt;a asp-action="Details" asp-route-id="@item.Id"&gt;Details&lt;/a&gt; |
                      &lt;a asp-action="Delete" asp-route-id="@item.Id"&gt;Delete&lt;/a&gt;
                  &lt;/td&gt;
              &lt;/tr&gt;
          }
      &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>