title: Nullable object must have a value in mvc
body: <p>When I run the website and I get this error:</p>
  
  <blockquote>
    <p>System.InvalidOperationException: 'Nullable object must have a value.'</p>
  </blockquote>
  
  <p>I have <code>Duzenle</code> controller and this included below codes:</p>
  
  <pre><code>[Authorize(Roles = "Sube")]
  public ActionResult Duzenle()
  {
      var date = DateTime.Now.Date;
      var kullanici = UserGetter.GetUser();
      var subeId = kullanici.SubeId.Value; // exception is thrown here
      var kasaRaporu = db.KasaRaporu
          .Where(kr =&gt; kr.SubeId == subeId).ToList()
          .Where(kr =&gt; kr.Tarih.Date == date).FirstOrDefault();
  
      if (kasaRaporu != null)
      {
          return View(kasaRaporu);
      }
  
      kasaRaporu = KasaRaporuCreator.Create(subeId);
      return View(kasaRaporu);
  }
  </code></pre>
  
  <p>The exception is thrown in this line:</p>
  
  <pre><code>var subeId = kullanici.SubeId.Value;
  </code></pre>
  
  <p>What is wrong?</p>