I am googling it since a while but unfortunately no clear solution found. The question could be separated to EF specific part and not EF specific part I know.
I have an web application (ASP.NET MVC) which uses SQL Server via EF 6. I would like to implement audit triggers, so I would like to be available some audit information to the trigger, like web logged in current user. I thought there should be some connection level parametrizing facility in SQL Server to initialize custom SET variables what can be accessed during that connection via SQL (in the triggers. The only thing I found is the way restricted CONTEXT_INFO()
which is binary.
I've also know temp tables what are connection local, but it seems to be a bit overkill to start all connection to create a temp table and insert a row.
However my biggest concern is connection pooling. It seems to me that a proposed solution either does not work correctly because of connection pooling (temp tables), either it effectively kills connection pooling. (connection string manipulation techniques)
Still I think this audit trigger, which must know web user name is so common and basic so I am hoping someone figured out the correct solution and it is available, I just can not find it.