title: EF: object update process is not changing value of one property
body: <p>my application has 2 classes: <code>PaymentMethod</code> &amp; <code>Currency</code> (<code>Currency</code> is property of <code>PaymentMethod</code>). When my app does update of <code>PaymentMethod</code> with new value of <code>Currency</code> propery (value already exists in db but it's being assigned to <code>PaymentMethod</code>), after <code>SaveCHanges</code> method, <code>Currency</code> property still contains old value. <strong>WHY?:)</strong></p>
  
  <p>this is how my application replaces Currency object value:</p>
  
  <pre><code> if (String.Compare(existingPaymentMethod.Currency.Code, mwbepaymentmethod.CurrencyCode, true) !=0)
              {
                  var readCurrency = currencyRepo.FindByCode(mwbepaymentmethod.CurrencyCode);
  
                  existingPaymentMethod.Currency = readCurrency;
  
              }
  
              paymentMethodRepository.Save(ref existingPaymentMethod);
              return true;
  </code></pre>
  
  <p><code>PaymentMethod</code> &amp; <code>Currency</code> classes:</p>
  
  <pre><code>public class PaymentMethod : BaseEntity
      {
          public enum MethodTypeEnum
          {
              Creditcard,
              Virtualcard,
              Wallet
          };
          public MethodTypeEnum MethodType { get; set; }
          public int VendorId { get; set; }
          public virtual Address BillingAddress { get; set; }
          public virtual Currency Currency { get; set; }
      }
  
  public class Currency : BaseEntity
      {
          [JsonProperty("code")]
          [Key]
          public string Code { get; set; }
  
          [JsonProperty("symbol")]
          public string Symbol { get; set; }
  
          [JsonIgnore]
          public virtual ICollection&lt;Payment&gt; Payments { get; set; }
  
          [JsonIgnore]
          public virtual ICollection&lt;PaymentMethod&gt; PaymentMethods { get; set; }
      }
  </code></pre>
  
  <p>Edit method:</p>
  
  <pre><code>public override void Edit(MwbePaymentMethod entityToUpdate)
          {
              DbSet.Attach(entityToUpdate);
              Context.Entry(entityToUpdate).State = EntityState.Modified;
  
              //manual update of  properties
              //Context.Entry(entityToUpdate.BillingAddress).State = EntityState.Modified;
              //Context.Entry(entityToUpdate.Currency).State = EntityState.Unchanged;
          }
  </code></pre>
  
  <p><code>OnModelCreating</code> method:</p>
  
  <pre><code> protected override void OnModelCreating(DbModelBuilder modelBuilder)
          {
              Database.SetInitializer(new DropCreateDatabaseIfModelChanges&lt;MobileWalletContext&gt;());
             ...
              modelBuilder.Entity&lt;MwbePaymentMethod&gt;().HasRequired(e =&gt; e.Currency).WithMany(e =&gt; e.PaymentMethods);
  
              base.OnModelCreating(modelBuilder);
          } 
  </code></pre>
  
  <p>DB context defined by Autofac:</p>
  
  <pre><code>builder.RegisterType&lt;MobileWalletContext&gt;().As&lt;IMwbeDbContext&gt;().InstancePerRequest();
  </code></pre>
  
  <p><strong>Update 1</strong>:
  EF logs shows no currency field update:</p>
  
  <pre><code>UPDATE [dbo].[MwbeAddress] SET [Street] = @0, [City] = @1, [ZipCode] = @2, [Country] = @3 WHERE ([Id] = @4)
  -- @0: 'FFFF12' (Type = String, Size = -1)
  -- @1: 'GlasgowSSSS' (Type = String, Size = -1)
  -- @2: 'B33 8TH' (Type = String, Size = -1)
  -- @3: 'England' (Type = String, Size = -1)
  -- @4: '2' (Type = Int32)
  -- Executing at 2015-07-13 07:35:48 +02:00
  -- Completed in 39 ms with result: 1
  
  UPDATE [dbo].[MwbePaymentMethod] SET [MethodType] = @0, [VendorId] = @1, [Number] = @2, [ExpirationDate] = @3, [Balance] = @4, [IsPending]
  = @5, [IsDefault] = @6 WHERE ([Id] = @7)
  -- @0: '1' (Type = Int32)
  -- @1: '0' (Type = Int32)
  -- @2: '4444 4444 4444 4450' (Type = String, Size = -1)
  -- @3: '2015-10-10 00:00:00' (Type = DateTime2)
  -- @4: '0' (Type = Double)
  -- @5: 'True' (Type = Boolean)
  -- @6: 'False' (Type = Boolean)
  -- @7: '3' (Type = Int32)
  -- Executing at 2015-07-13 07:35:48 +02:00
  -- Completed in 7 ms with result: 1
  </code></pre>
  
  <p><strong>Why there is not update for <code>Currency</code> property?</strong></p>