title: Referential Integrity Constraint violation when attempting to set a FK to null
body: <p>I am trying to update an entity in EF6. I have read that if I wish to change a ForeignKey property, I have to then ensure the Navigation Property is the correct one, or set it to null.</p>
  
  <p>I have taken the set to null approach, but I still receive the Referential Integrity Constraint Exception:</p>
  
  <pre><code>A referential integrity constraint violation occurred: The property value(s) of 'Contact.idContact' on one end of a relationship do not match the property value(s) of 'Entity.id_EntityContactInfo' on the other end.
  </code></pre>
  
  <p>But you can see in the debugger, that Entity.Contact is null, so I believe this shouldn't be throwing.</p>
  
  <p><img src="https://i.stack.imgur.com/LDXXp.png" alt="enter image description here"></p>
  
  <p>Any Ideas?</p>
  
  <p>EDIT</p>
  
  <p>This is how the entity is updated:</p>
  
  <pre><code>public T CommitUpdate&lt;T&gt;(T obj) where T : class
      {
          _DbContext.Set&lt;T&gt;().Attach(obj);
          _DbContext.Entry(obj).State = EntityState.Modified;
          _DbContext.Commit();
          return obj;
      }
  </code></pre>