title: How to set dbms_session.set_identifier from Entity Framework
body: <p>I am trying to implement audit trail in a web application that is backed by an Oracle Database, we do have  audit trail triggers in place that work flawlessly, when user alters data either via SQL client like TOAD or when I manually use Oracle.DataAccess.Client via </p>
  
  <pre><code>        // rest omitted for brevity // 
  
          var command = new OracleCommand();
          command.Connection = conn;
  
  
          var useridsql = new StringBuilder();
  
          useridsql.AppendLine("BEGIN");
          useridsql.AppendLine("dbms_session.set_identifier('username');");
          useridsql.AppendLine("END;");
  
  
  
          command.CommandText = useridsql.ToString();
  
          command.ExecuteNonQuery(); 
       // Rest of the insert / update / delete code // 
  </code></pre>
  
  <p>What doesn't work is when I try to do the same by overriding SaveChanges() in DbContext class. </p>
  
  <p>I assume that Entity is using a different from the above ADO.NET example on how it manages its connections and hence the reason that the update is happening but on a wrong Database session hence the dbms_session is not visible to the trigger.</p>
  
  <p>I did try turning connection pooling off, that wasnt much of help either. </p>
  
  <p>I have tried all possible scenarios known to me but without any success. </p>
  
  <p>Does anyone here have an idea and could push me in the right direction. </p>
  
  <p>Thanks in advance, your help is much appreciated. </p>
  
  <p>with kind regards, </p>
  
  <p>Max. </p>