title: Update owned entity EF Core 5
body: <p>I am implementing an api using .net 5.
  I have a student class which have a property with address type(value object according to ddd).</p>
  <pre><code>public class Student 
  {
          public long Id{ get; private set; }
          public string FirstName { get; private set; }
          public string LastName { get; private set; }
          public Address Address { get; private set; }
  }
  
  public class Address
  {
      public string City { get; private set; }
      public string Road { get; private set; }
  }
  </code></pre>
  <p>I am using fluent api to configure the database using ef core 5.</p>
  <pre><code> class StudentConfiguration : IEntityTypeConfiguration&lt;Student&gt;
      {
  
          public void Configure(EntityTypeBuilder&lt;Student&gt; builder)
          {
              builder.ToTable(&quot;Students&quot;);
              builder.HasKey(x =&gt; x.Id);
  
              builder.Property(x =&gt; x.Id).ValueGeneratedNever().IsRequired();
              builder.Property(x =&gt; x.FirstName).HasMaxLength(25).IsRequired();
              builder.Property(x =&gt; x.LastName).HasMaxLength(50).IsRequired();           
  
  
              builder.OwnsOne(x =&gt; x.Address, x =&gt;
              {
                  x.Property(pp =&gt; pp.City)
                      .IsRequired()
                      .HasColumnName(&quot;City&quot;)
                      .HasMaxLength(20);
                  x.Property(pp =&gt; pp.Road)
                      .IsRequired()
                      .HasColumnName(&quot;Road&quot;)
                      .HasMaxLength(40);
              });
  
          }
      }
  </code></pre>
  <p>As a result I have one table with columns Id,Fistname,lastname,city,road.</p>
  <p>Now I am trying to update only the city and the road(for example a student change house)
  but I have different exceptions and I don't know how to update only these 2 columns</p>
  <pre><code>public async Task UpdateAddress(Student student)
  {
  //Firts try 
              //var studentEntry = context.Entry(student);
              //studentEntry.Property(x =&gt; x.Address.City).IsModified = true;
              //studentEntry.Property(x =&gt; x.Address.Road).IsModified = true;
              //**Exception** 'The expression 'x =&gt; x.Address.City' is not a valid member access expression. The expression should represent a simple property or field access: 't =&gt; t.MyProperty'. (Parameter 'memberAccessExpression')'
  
  //Second try 
               //var studentEntry = context.Entry(student.Address);
              //studentEntry.Property(x =&gt; x.City).IsModified = true;
              //studentEntry.Property(x =&gt; x.Road).IsModified = true;
              //**Exception** '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. 
  
  //the only method that works is Update but this update the whole object
       context.Update(student);
       await context.SaveChangesAsync();
  }
  </code></pre>
  <p>EDIT</p>
  <pre><code>public class StudentDbContext : DbContext
      {
          public DbSet&lt;Student&gt; Students { get; set; }
  
          public StudentDbContext(DbContextOptions&lt;StudentDbContext&gt; options) : base(options)
          {
              ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;
          }
  
          protected override void OnModelCreating(ModelBuilder modelBuilder)
          {
              modelBuilder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly());
              base.OnModelCreating(modelBuilder);
          }
      }
  </code></pre>
  <p>How can update only these two properties of an owned entity?</p>