title: Owned types collection is never updated in EF Core
body: <p>I have an aggregate defined like this:</p>
  
  <pre><code>public class Product {
      public int LocalId { get; private set; }
      public Something Something { get; private set; }
      public ICollection&lt;Price&gt; Prices { get; private set; }
  }
  
  public class Something {
      public string Name { get; set; }
  }
  
  public class Price {
      public int Type { get; set; }
      public decimal Value { get; set; }
  }
  </code></pre>
  
  <p>And a schema defined like this:</p>
  
  <pre><code>private void DefineProduct(ModelBuilder builder) =&gt;
      builder
          .Entity&lt;Product&gt;(builder =&gt;
          {
              builder.HasKey(p =&gt; p.LocalId);
              builder
                  .OwnsOne(p =&gt; p.Something, smth =&gt;
                  {
                      smth.ToTable("somethings");
                  })
                  .OwnsMany(p =&gt; p.Prices, pp =&gt;
                  {
                      pp.ToTable("prices");
                  });
          });
  </code></pre>
  
  <p>When a price change is requested, I do this (inside the product method not included here for brevity):</p>
  
  <pre><code>Prices.First(p =&gt; p.Type == type).Value = newValue;
  </code></pre>
  
  <p>And then I try to save the product like this:</p>
  
  <pre><code>public async Task UpdateProperties(Product product, IEnumerable&lt;object&gt; props)
  {
      _context.Attach(product);
      _context.Update(product);
  
      foreach (var prop in props)
      {
          _context.Update(prop);
      }
  
      try
      {
          await _context.SaveChangesAsync();
      } 
      catch (Exception ex)
      {
          Console.WriteLine("Who the hell allowed such a bug to go into a production release?");
      }
  }
  </code></pre>
  
  <p>Now I should mention that the product comes in from an initial query whose results were not tracked (via <code>AsNoTracking()</code> call), that's why I'm calling the <code>Attach</code> method in the first line of the method body. The problem is that I'm hitting that <code>catch</code> statement with an exception message saying:</p>
  
  <blockquote>
    <p>Database operation expected to affect 1 row(s) but actually affected 0
    row(s). Data may have been modified or deleted since entities were
    loaded. See <a href="http://go.microsoft.com/fwlink/?LinkId=527962" rel="nofollow noreferrer">http://go.microsoft.com/fwlink/?LinkId=527962</a> for
    information on understanding and handling optimistic concurrency
    exceptions."}</p>
  </blockquote>
  
  <p>The thing is that I'm not updating the same product anywhere else and that's the only place touching it. Also I use <code>AsNoTracking</code> as the default. If I comment out the line with <code>_context.Update(prop);</code>, then there's no exception raised, but the price is not being updated. Also, if I don't update that prices collection but the <code>Something</code> property, everything goes well. What. The. Hell.</p>