views:

97

answers:

2

We are running several calls against a SQL Server database within a transaction scope using entity framework.

Are we right is assuming that the SPID will be held for the duration of the transaction and that all calls will be made on the same SPID?

A: 

Yes, the SPID will be the same for the duration of the transaction.

Barry King
@Barry, thanks for the answer, but we found out that we do not have the same SPID for the duration of the transaction.
Shiraz Bhaiji
A: 

We found out that a SPID is connected to a connection, not to a transaction.

But EF will close and open a connection in order to enlist it in a transaction.

The connection is not actually closed in is released to the connection pool and then retrieved again.

The problem is then that you may not get the same connection back from the connection pool, in which case you will not have the same SPID.

Shiraz Bhaiji