title: How to set null value to an existing attribute on Entity Framework
body: <p><strong>Scenario:</strong><br>
  I have an entity with a (nullable) FK <code>Id</code> that it's not required anymore.</p>
  
  <p><strong>Problem:</strong><br>
  When I update this entity on the context, setting <code>NULL</code> to the FK, after the <code>SaveChanges()</code> the value is not persisted on the db.</p>
  
  <p>Any ideas?</p>
  
  <p><strong>Edit #1:</strong><br>
  After the <code>SaveChanges</code>, I checked the base and continues the old value, and if I change to other value works fine.</p>
  
  <p><strong>Class:</strong></p>
  
  <pre><code>public class Account
  {
      [Required]
      public int Id { get; set; }
  
      public int? PlanId { get; set; }
  
      [Required]
      public virtual Status Status { get; set; }
  
      #region Navigations Properties
  
      public virtual Plan Plan { get; set; }
  
      #endregion
  }
  </code></pre>
  
  <p><strong>Usage:</strong> (Problem)</p>
  
  <pre><code>Account ent = Context.Set&lt;Account&gt;().AsQueryable().FirstOrDefault(x =&gt; x.Id = id);
  ent.PlanId = null;
  Context.SaveChanges();
  </code></pre>
  
  <p><strong>Edit [PROBLEM SOLVED]</strong></p>
  
  <p>It was necessary to send an array with the fields that would get null as the new value.</p>
  
  <pre><code>public virtual void Update(TEntity entityToUpdate, List&lt;string&gt; updateNullFields)
  {
      DbSet.Attach(entityToUpdate);
      foreach (var item in updateNullFields)
      {
          Context.Entry(entityToUpdate).Property(item).IsModified = true;
      }
  }
  </code></pre>