title: the property id is part of the object's key information and cannot be modified
body: <p>When I trying  to update a data with EF I got error its like </p>
  
  <blockquote>
    <p>the property id is part of the object's key information and cannot be
    modified</p>
  </blockquote>
  
  <p>Thıs ıs wınForm Application
  you can see my update method here</p>
  
  <h1>region Update</h1>
  
  <pre><code>        try
          {
              _truck.plateNumber= txtplateNumber.Text;
              _truck.brand = txtMarka.Text;
              _truck.model = txtModel.Text;
              _truck.type = txtTipi.Text;
              _truck.registrationDate = dtregistrationDate.Value;
              _truck.examinationDate = dtexaminationDate.Value;
              _truck.Description = txtDescription.Text;
              _truck.driverName = txtdriverName.Text;
              _truck.weight= txtweight.Text;
              _truck.Id = Convert.ToInt32(txtplateNumber.Tag);
              _truck.userId = Tools.Tools.getUserId();
  
              #region update
              currentItem = cr.getbyId(Convert.ToInt32(txtplateNumber.Tag.ToString())).plateNumber;
  
              if (currentItem != null)
              {
                  if (!currentItem.Equals(txtplateNumber.Text))
                  {
                      if (!cr.isPlateAlreadyExist(txtplateNumber.Text))
                      {
                         DialogResult result = MessageBox.Show("Are you sure want to update to Truck?", "Update", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                          if (result == DialogResult.Yes)
                          {
                              if (!string.IsNullOrEmpty(this.pbLicence.ImageLocation))
                              {
                                  _truck.licencePicture = Tools.Tools.convertToByteFfromImageF(pbLicence.Image);
  
                                  if (!cr.getbyId(Convert.ToInt32(txtplateNumber.Tag)).hasPicture)
                                  {
                                      _truck.hasPicture = true;
                                      cr.Update(_truck);
                                  }
                              }
  
                              cr.Update(_truck);
                              MessageBox.Show("Successfuly");
  
                          }
                          else
                          {
                              MessageBox.Show("The process was Cancel !", "Canceled", MessageBoxButtons.OK, MessageBoxIcon.Information);
                          }
                      }
                      else
                      {
                          MessageBox.Show("The plate number is already Exists.", "Same Plate Number", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                      }
                  }
                  else
                  {
                      DialogResult result = MessageBox.Show("Are you sure want to update to Truck?", "Update", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                      if (result == DialogResult.Yes)
                      {
                          if (!string.IsNullOrEmpty(this.pbLicence.ImageLocation))
                          {
                              _truck.licencePicture = Tools.Tools.convertToByteFfromImageF(this.pbLicence.Image);
  
                              if (!cr.getbyId(Convert.ToInt32(txtplateNumber.Tag)).hasPicture)
                              {
                                  _truck.hasPicture = true;
                                  cr.Update(_truck);
                              }
                          }
  
                          cr.Update(_truck);
                          MessageBox.Show("SuccessFully");
                      }
  
                  }
              #endregion
              }
              else
              {
                  MessageBox.Show("You did not select an Item","Warning");
              }
          }
          catch (Exception ex)
          {
              MessageBox.Show("Error:" + ex.Message, "Error");
          }
          finally
          {
              getUpdatedList();
              Tools.Tools.clearAllFormControlsContent(pickTruckControls());
          }
          #endregion
  </code></pre>
  
  <p>------Repository Update method---------</p>
  
  <pre><code>public int Update(Truck item)
      {
          Truck updated = db.Trucks.Where(x =&gt; x.Id == item.Id).FirstOrDefault();
          db.Entry(updated).CurrentValues.SetValues(item);
          return db.SaveChanges();
      }
  </code></pre>