Entity Framework not updating existing related entity
<p>I have a project which uses Entity Framework extensively. And it all works fine.</p>

<p>However, there is one update that I am trying to make and it does not update, nor is an error thrown.</p>

<p>The basic process is that I take an existing entity, work with it to create a new (and different type) of entity. The new entity saves just fine, but the existing one does not.</p>

<p>Typically when I have encountered this, it means that the entity is not attached to the context. However, it is, and I have tried attaching it again as well as "Adding" it, but I have had no luck.</p>

<pre><code>        if (fileRowEntity != null)
        {
            this.Context.FileRowEntities.Attach(fileRowEntity);
            fileRowEntity.FileRowStatusId = (int)FileRowStatus.Converted;
            fileRowEntity.EdiDocument = ediDocument;
        }

        ediDocument.InsertedDate = DateTime.Now;
        ediDocument.EdiDocumentGuid = Guid.NewGuid();
        ediDocument.DocumentMetatdata = null;
        this.Context.EdiDocuments.Add(ediDocument);
        var count = this.Context.SaveChanges();
</code></pre>

<p>The <code>ediDocument</code> is saved, but the <code>fileRowEntity</code> is not saved.</p>

<p>I am tearing my hair out trying to figure this out.  I have tried a second explicit save on the <code>fileRowEntity</code> but it comes back with zero changes saved:</p>

<pre><code>        if (fileRowEntity != null)
        {
            fileRowEntity.EdiDocumentId = ediDocument.EdiDocumentId;
            fileRowEntity.Column100 = "X";
            this.Context.FileRowEntities.Attach(fileRowEntity);
            count = this.Context.SaveChanges();
        }
</code></pre>

<p><code>count</code> is always zero, and the database is not updated.</p>

<p>I don't know what else to try to debug this.</p>