title: Updating a record using a class object with Entity Framework in C#
body: <p>I have an entity class which includes many fields.
  To make it simple, let's assume the class is defined as following:</p>
  
  <pre><code>public partial class Branches
  {
  
      public int num { get; set; }
      public string name { get; set; }
      public string street { get; set; }
      public string city { get; set; }
  </code></pre>
  
  <p>In my API class, I want to define a function for updating a record of this type.
  As creating a function to update each field separately seems like quite an overhead for my application, I decided to define one function that updates all fields.
  Can I assign the object received by the function directly to the object used for the update as following?</p>
  
  <pre><code>void updateBranch(Branches branch)
  {
    using (var dbContext = new entitiesContext())
    {
      var result = dbContext.Branches.SingleOrDefault(b =&gt; b.num == branch.num);                                                
      if (result != null)
      {
        **result = branch;**                        
        dbContext.SaveChanges();
      }
    }
  }
  </code></pre>
  
  <p>I'm using Entity Framework version 6.0</p>