title: Entity Framework 6.0 FirstOrDefault() Object reference not set to an instance of an object
body: <p>All of a sudden I'm getting an error:  Object reference not set to an instance of an object. I'm using Entity Framework 6.0 and everything was working and all of a sudden everything stopped code:</p>
  
  <pre><code>List&lt;Price&gt; prices = db.Prices.ToList() ?? new List&lt;Price&gt;();
  if ( prices != null &amp;&amp; prices.Any() )
  {
        // Price is a data model generated by edmx
        Price price = prices.FirstOrDefault();
  }
  </code></pre>
  
  <p>Anyone knows what could've changed? I've seen other threads have Glimpse in their stack trace but mine doesn't have it, Stack Trace:</p>
  
  <pre><code>at ASP._Page_Views_FAStock__VehiclePrices_cshtml.Execute() in c:\wamp\www\netauto.co.za\apcloud.co.za\ApCloud\ApCloud.SM.UI\Views\FAStock\_VehiclePrices.cshtml:line 96
     at System.Web.WebPages.WebPageBase.ExecutePageHierarchy()
     at System.Web.Mvc.WebViewPage.ExecutePageHierarchy()
     at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)
     at System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance)
     at System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer)
     at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context)
     at System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult)
     at System.Web.Mvc.ControllerActionInvoker.&lt;&gt;c__DisplayClass1a.&lt;InvokeActionResultWithFilters&gt;b__17()
     at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation)
  </code></pre>