I'd like to use SQL Server traces to track more context about what code is using the database. I was going to use the "Application Name" property on the connection string. That looks something like the following:
object CallingObject; //set elsewhere
SqlConnectionStringBuilder connectionString = GetConnectionString();
connectionString.ApplicationName = CallingObject.GetType().ToString();
using (SqlConnection connection = new SqlConnection(connectionString.ToString()))
{
// do your thing
}
Except that the large variety of resulting connection strings would mean that .net's Connection Pooling is no longer effective.
How can I track calling code in a SQL Trace without losing the benefit of connection pooling?