title: Replacing Endpoint of 1 to 0 or 1 Relationship
body: <p>I have models that look something like the following representing a 1 to 0 or 1 relationship.</p>
  
  <pre><code>public class Parent
  {
      public int ParentId { get; set; }
      public Child Child { get; set; }
  }
  
  public class Child
  {
      [Key, ForeignKey("Parent")]
      public int ChildId { get; set; }
  
      public Parent Parent { get; set; }
  }
  </code></pre>
  
  <p>I have the need to replace the Child member of Parent.  A new instance is being received from an outside source.</p>
  
  <p>However, after replacing the Child and attempting to save to the database:</p>
  
  <pre><code>parent.Child = &lt;new instance&gt;
  context.Entry(parent).State = EntityState.Modified;
  </code></pre>
  
  <p>I receive the error </p>
  
  <blockquote>
    <p>"A referential integrity constraint violation occurred: The property
    value(s) of 'Parent.ParentId' on one end of a relationship do not
    match the property value(s) of 'Child.ChildId' on the other end."</p>
  </blockquote>
  
  <p>How can I replace the endpoint?  How can I remove it?  Thanks</p>