title: Getting Error On Updating Entity Framework
body: <p>I am getting an error during DBUpdation Exception exception of a particular entry in the table.</p>
  
  <p>Cannot add or update a child row: a foreign key constraint fails, however the USerID exist in appuser table.</p>
  
  <p>First I will update one of the column to false, then add a new entry to the table for the same userID. The same code is working fine in local environment.</p>
  
  <pre><code>System.Data.Entity.Infrastructure.DbUpdateException: An error occurred while updating the entries. See the inner exception for details. ---&gt; System.Data.UpdateException: An error occurred while updating the entries. See the inner exception for details. ---&gt; MySql.Data.MySqlClient.MySqlException: Cannot add or update a child row: a foreign key constraint fails (`asd34556`.`freeattribute`, CONSTRAINT `FK_FreeAttr_UserID_ApUser_UserID` FOREIGN KEY (`UserID`) REFERENCES `appuser` (`UserID`) ON DELETE NO ACTION ON UPDATE NO ACTION)
  at MySql.Data.MySqlClient.MySqlStream.ReadPacket()
  at MySql.Data.MySqlClient.NativeDriver.GetResult(Int32&amp; affectedRow, Int64&amp; insertedId)
  at MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force)
  at MySql.Data.MySqlClient.MySqlDataReader.NextResult()
  at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
  at MySql.Data.Entity.EFMySqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
  at System.Data.Mapping.Update.Internal.DynamicUpdateCommand.Execute(UpdateTranslator translator, EntityConnection connection, Dictionary`2 identifierValues, List`1 generatedValues)
  at System.Data.Mapping.Update.Internal.UpdateTranslator.Update(IEntityStateManager stateManager, IEntityAdapter adapter)
  --- End of inner exception stack trace ---
  at System.Data.Mapping.Update.Internal.UpdateTranslator.Update(IEntityStateManager stateManager, IEntityAdapter adapter)
  at System.Data.Objects.ObjectContext.SaveChanges(SaveOptions options)
  at System.Data.Entity.Internal.InternalContext.SaveChanges()
  --- End of inner exception stack trace ---
  at System.Data.Entity.Internal.InternalContext.SaveChanges()
  at FreeLance.Business.ProfileManagement.ProfileManagementBC.UpdateOtherDetails(appuser user)
  at FreeLance.Web.Controllers.ManageProfileController.OtherInfoUpdate(ProfileModel model)
  at lambda_method(Closure , ControllerBase , Object[] )
  at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
  at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
  at System.Web.Mvc.Async.AsyncControllerActionInvoker.&lt;&gt;c__DisplayClass37.&lt;&gt;c__DisplayClass39.&lt;BeginInvokeActionMethodWithFilters&gt;b__33()
  at System.Web.Mvc.Async.AsyncControllerActionInvoker.&lt;&gt;c__DisplayClass4f.&lt;InvokeActionMethodFilterAsynchronously&gt;b__49()
  at System.Web.Mvc.Async.AsyncControllerActionInvoker.&lt;&gt;c__DisplayClass4f.&lt;InvokeActionMethodFilterAsynchronously&gt;b__49()
  at System.Web.Mvc.Async.AsyncControllerActionInvoker.&lt;&gt;c__DisplayClass37.&lt;BeginInvokeActionMethodWithFilters&gt;b__36(IAsyncResult asyncResult)
  at System.Web.Mvc.Async.AsyncControllerActionInvoker.&lt;&gt;c__DisplayClass25.&lt;&gt;c__DisplayClass2a.&lt;BeginInvokeAction&gt;b__20()
  at System.Web.Mvc.Async.AsyncControllerActionInvoker.&lt;&gt;c__DisplayClass25.&lt;BeginInvokeAction&gt;b__22(IAsyncResult asyncResult)
  </code></pre>