title: When i Update my existing data System.Reflection.TargetException ERROR
body: <p>I am using web api to insert update read delete data from database using angularjs ajax but when i update my data i get error.</p>
  
  <p>My WEB API code for Update:</p>
  
  <pre><code>    [Route("api/UpdateAdmin")]
      [HttpPost]
      public bool UpdateAdmin(Admin admin)
      {
          using (FirstdbEntities ent = new FirstdbEntities())
          {
              Admin updatedAdmin = (from c in ent.Admins where c.Name == admin.Name select 
   c).FirstOrDefault();   //here i get the error System.Reflection.TargetException.
              updatedAdmin.City = admin.City;
              updatedAdmin.Role = admin.Role;
              ent.SaveChanges();
          }
          return true;
      }
  </code></pre>
  
  <p>my angularjs code that is implemented on click of button:</p>
  
  <pre><code>   $scope.Update = function (x) {
              var admin = $scope.adminlist[x];
              var httprequest = $http({
                  method: 'POST',
                  url: "api/UpdateAdmin/",
                  data: JSON.stringify(admin),
                  dataType: 'json',
                  headers: { "Content-Type": "application/json" }
              })
              .then(function (data) {
                  alert('Data Updated successfully.');
                  $scope.adminlist.push(data.data);
              });
          }
  </code></pre>
  
  <p>my button:</p>
  
  <pre><code>&lt;input type="button" class="bg-danger" value="Update" ng-click="Update(ax)" /&gt;
  </code></pre>
  
  <p>Kindly advice me what to do.Thanks!!</p>