Setting Oracle session variables prior to database read/write events in Entity Framework / ODP.NET
You could try doing it when the connection state changed from closed to open. Like this...
public partial class MyContext : DbContext{ public MyContext() { this.Database.Connection.StateChange += Connection_StateChange; } void Connection_StateChange( object sender, System.Data.StateChangeEventArgs e ) { if ( e.CurrentState == System.Data.ConnectionState.Open ) { if ( sender is System.Data.Common.DbConnection ) { var command = ( sender as System.Data.Common.DbConnection ).CreateCommand(); command.CommandText = "SESSIONCOMMAND"; command.CommandType = System.Data.CommandType.Text; command.ExecuteNonQuery(); } } }