title: 1-to-1 relationship causing exception: AssociationSet is in the 'Deleted' state. Given multiplicity constraints
body: <p>I have set up a 1-to-1 relationship using EF code first following the method prescribed here:</p>
  
  <p><a href="https://stackoverflow.com/questions/10466660/unidirectional-one-to-one-relationship-in-entity-framework">Unidirectional One-To-One relationship in Entity Framework</a></p>
  
  <p>My mapping looks like this ...</p>
  
  <pre><code>protected override void OnModelCreating(DbModelBuilder modelBuilder)
  {
      modelBuilder.Entity&lt;Asset&gt;()
          .HasRequired(i =&gt; i.NewsItem)
          .WithOptional(e =&gt; e.Asset)
          .Map(m =&gt; m.MapKey("NewsItemId"));
  }
  </code></pre>
  
  <p>But when I get this exception ...</p>
  
  <blockquote>
    <p>A relationship from the 'Asset_NewsItem' AssociationSet is in the 'Deleted' state. Given multiplicity constraints, a corresponding 'Asset_NewsItem_Source' must also in the 'Deleted' state.</p>
  </blockquote>
  
  <p>Whenever this code runs:</p>
  
  <pre><code>var entry = _db.NewsItems.Find(id);
  
  entry.Asset = new Asset();
  
  _db.DbContext.SaveChanges();
  </code></pre>
  
  <p>I can get things to work if I explicitly mark the previous Asset associated to the NewsItem for deletion, BUT it just seems kinda wonky.  It seems like, based on the mapping, the above code should simply work ... replacing the old Asset with the new one.</p>
  
  <p>Am I doing something wrong?  Is there something I need to specify in the mapping that will get things working right?  Or, is it simply the EF way to have to delete and then add associated objects like this?</p>