title: How to update a single property in Entity Framework Core
body: <p>I need to update only one or two properties of an Entity. In other words, I have an entity with an Id, ParentId, Name, and Description.</p>
  <p>The issue is that when the name is updated, the Description is wiped out if it already existed in the database.</p>
  <p>This is the code:</p>
  <pre class="lang-cs prettyprint-override"><code>internal void Update(ItemInfo itemInfo)
  {
      var item = new Item { Id = itemInfo.Id, ParentId = itemInfo.ParentId, Name = itemInfo.Name };
      var entry = this.DbContext.Items.Attach(item);
      if (item.ParentId != null) entry.Property(x =&gt; x.ParentId).IsModified = true;
      if (!(String.IsNullOrWhiteSpace(item.Name))) entry.Property(x =&gt; x.Name).IsModified = true;
      this.SaveChanges();;
  }
  </code></pre>
  <p>I thought that since I was setting the particular property as modified, only that property would be updated.</p>
  <p>Or should I be getting the entity from the database first, and then just setting the property and saving.  I wanted to avoid two trips to the database for a single save.</p>