title: null reference exception on view mvc .NET
body: <p>I have a populated database, But when I want to return a single value in a view Visual studio pointer to a System.NullReferenceException' occurred in App_Web_qoycb13m.dll but was not handled in user code. Why is this happening ?</p>
  
  <p>The line of error is:</p>
  
  <pre><code>&lt;h2&gt;@Model.Name&lt;/h2&gt;
  </code></pre>
  
  <p>The controller:</p>
  
  <pre><code>    public ActionResult Detail(int? MovieID)
      {
          var movie = _movie.Movies.Include(m =&gt; m.Genre).SingleOrDefault(m =&gt; m.Id == MovieID);
          return View(movie);
      }
  </code></pre>
  
  <p>The view:</p>
  
  <pre><code>    @model Viddly.Models.Movie
  
      @{
          ViewBag.Title = "Detail";
          Layout = "~/Views/Shared/_Layout.cshtml";
      }
  
      &lt;h2&gt;@Model.Name&lt;/h2&gt;
  </code></pre>
  
  <p>The Index page to click and change the page by MovieID:</p>
  
  <pre><code>    @model IEnumerable&lt;Viddly.Models.Movie&gt;
  @{
      ViewBag.Title = "Movie";
      Layout = "~/Views/Shared/_Layout.cshtml";
  }
  
  &lt;h2&gt;Movies&lt;/h2&gt;
  
  
  &lt;table class="table table-bordered table-hover"&gt;
      &lt;tbody&gt;
          &lt;thead&gt;
              &lt;tr&gt;
                  &lt;th&gt;Movies&lt;/th&gt;
                  &lt;th&gt;Genre&lt;/th&gt;
              &lt;/tr&gt;
          &lt;/thead&gt;
          @foreach (var movie in Model)
          {
              &lt;tr&gt;
  
                  &lt;td&gt;@Html.ActionLink(movie.Name, "Detail", new { movie.Id})&lt;/td&gt;
                  &lt;td&gt;@movie.Genre.GenreType&lt;/td&gt;
              &lt;/tr&gt;
          }
      &lt;/tbody&gt;
  
  &lt;/table&gt;
  </code></pre>
  
  <p>And its my RouteConfig.cs:</p>
  
  <pre><code> routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
  
  
  
          routes.MapRoute(
              name: "CustomerDetails",
              url: "{controller}/{Detail}/{CustomerID}",
              defaults: new { controller = "Customer", action = "Detail" }
          );
  
          routes.MapRoute(
             name: "MovieDetails",
             url: "{controller}/{Detail}/{MovieID}",
             defaults: new { controller = "Movie", action = "Detail" }
         );
  
          routes.MapRoute(
              name: "Default",
              url: "{controller}/{action}/{id}",
              defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
          );
  </code></pre>
  
  <p><strong>EDITED</strong></p>