Run real-time SQL tracing at application level with a ORM….

If you ever need to know exactly what dml your application is running as you have an ORM as your persistence layer like NHiberate. The most effective way is to add an application name parameter to your ado connection string and use SQL Server Profiler, to listen for this application, see below:-

Change application’s ado connection string:-

“Data Source=XXXXX;Initial Catalog=XXXXXX;Integrated Security=True;Pooling=False”


“Data Source=XXXXX;Initial Catalog=XXXXXX;Integrated Security=True;Pooling=False;Application Name=GOSQL”

Go to SQL Server Profiler, start a new profile using the standard ‘SQL’ profile.

On the ‘Events Selection’ tab select ‘Show all columns’.

Select ‘Column Filters’.

Select ‘ApplicatioName’ expand ‘Like’ enter your application name, and select ‘Exclude rows that do not contain values’.

Select ‘OK’, and ‘Run’.

Any request coming through as your application name will be profiles for analyzing later.

This is a very good technique if your are trying to identify what dml the ORM is rendering under the hood. Once you have identified your the dml, you can tackle your problem with a better understanding of what the application and database are trying to do.Image


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s