Answers Please check whether the related entities have already exist in the database. I think it caused by the child objects are not exist in database, so when you do attach operation, the exception is thrown. If detach the entity before serializing, the child objects are cleared, so the exception will not thrown. All Replies Please check whether the related entities have already exist in the database. I think it caused by the child objects are not exist in database, so when you do attach operation, the exception is thrown. If detach the entity before serializing, the child objects are cleared, so the exception will not thrown. I think you can check the total count first. Try to query out the total count of the child entities in the 'emp' entity, and then query out the total number in the database, check if the total number is same.