title: Entity Framework - Setting a "Nullable" integer to null
body: <p>I have a table in my DB called <code>Login</code>. In this table I have an attribute called <code>Head_ID</code>, which is nullable.</p>
  
  <p>Basically, you can have a chief, or you ARE the chief. In the case that you're the chief, the <code>Head_ID</code> should be null. In my application I have the possibility to change one's chief (Coworker changes chief, chief gets downgraded and get's a chief above him), but this <code>int</code> won't be set to </p>
  
  <p><strong>Service.cs</strong> </p>
  
  <pre><code>public int EditLogin(LoginDTO login)
      {
          try
          {
              var dbLogin = DAO.HourRegInstance.Login.Single(x =&gt; x.ID == login.Id);
              dbLogin.Name = login.Name;
              dbLogin.Username = login.Username;
              if (login.Head_Id == 0)
              {
                  //Doesn't work
                  dbLogin.Head_ID = null;
              }
              dbLogin.Role_ID = login.Role_Id;
              DAO.HourRegInstance.SaveChanges();
              return 1;
          } catch(Exception e){
              return -1;
          }
      }
  </code></pre>
  
  <p><strong>Login.cs</strong></p>
  
  <pre><code>public partial class Login
  {
      public Login()
      {
          this.HourRegistrationConfirmed = new HashSet&lt;HourRegistrationConfirmed&gt;();
          this.HourRegistrationConfirmed1 = new HashSet&lt;HourRegistrationConfirmed&gt;();
          this.Login1 = new HashSet&lt;Login&gt;();
          this.LoginProject = new HashSet&lt;LoginProject&gt;();
      }
  
      public long ID { get; set; }
      public string Name { get; set; }
      public string Username { get; set; }
      public string Password { get; set; }
      public long Role_ID { get; set; }
      public Nullable&lt;long&gt; Head_ID { get; set; }
  
      public virtual ICollection&lt;HourRegistrationConfirmed&gt; HourRegistrationConfirmed { get; set; }
      public virtual ICollection&lt;HourRegistrationConfirmed&gt; HourRegistrationConfirmed1 { get; set; }
      public virtual ICollection&lt;Login&gt; Login1 { get; set; }
      public virtual Login Login2 { get; set; }
      public virtual Role Role { get; set; }
      public virtual ICollection&lt;LoginProject&gt; LoginProject { get; set; }
  }
  </code></pre>
  
  <p>How does one accomplish such task?</p>