title: Same exception in second try catch "insert statement conflicted with the foreign key constraint"
body: <pre><code>[Route("API/Add")]
  
  [HttpPost]
  public GenericClasss AddData(CAddData_Request Data)
  {
          GenericClasss Obj = new GenericClasss();
  
          try
          {
              Obj = _Base.AddDataa(Data);                   
          }
          catch (System.Exception ex)
          {
              string JsonData = _Base.ConvertJsontoString(Data);
              _Base.ServiceLogException(ex, ActionContext.ActionDescriptor.ActionName, JsonData);
          }
  
          return Obj;
      }    
  }
  
  public void ServiceLogException(System.Exception ex, string MethodName, string Data)
  {
      try
      {
          AppException _Exception = new AppException();
          _Exception.Employee_ID = null;
          _Exception.Method = MethodName;
          _Exception.Page = "";
          _Exception.Line = ex == null ? "0" : Convert.ToString(new System.Diagnostics.StackTrace(ex, true).GetFrame(0).GetFileLineNumber());
          _Exception.Object = Data;
          _Exception.Message = ex == null ? null : ex.Message;
          _Exception.CreatedDate = System.DateTime.UtcNow;
          _Exception.ExceptionType = 2;
          _Exception.IsSolved = false;
  
          DB.AppExceptions.Add(_Exception);
          DB.SaveChanges();
      }
      catch (Exception exa)
      {
      }
  }
  </code></pre>
  
  <p><strong>Problem:</strong></p>
  
  <p>If the <code>AddData</code> method generates an exception </p>
  
  <blockquote>
    <p>Insert statement conflicted with the foreign key constraint</p>
  </blockquote>
  
  <p>then it will go to the catch block and insert the exception entry into the database.</p>
  
  <p>But my <code>ServiceLogException</code> method also generates the same exception </p>
  
  <blockquote>
    <p>Insert statement conflicted with the foreign key constraint</p>
  </blockquote>