Hi, I am trying to use hangfire with an old project. There is not an option for me to use TransactionScope because multiple SqlConnections can be opened at the same time and that needs MSDTC support which i can not supply.
So, while searching the forum, i saw a usage like this;
var storage = new SqlServerStorage(mySqlConnection);
var client = new BackgroundJobClient(storage);
But when i use mySqlConnection with a transaction which is already started, i get an eror when i call client.Enqueue method ;
“ExecuteReader requires the command to have a transaction when the connection assigned to the command is in a pending local transaction. The Transaction property of the command has not been initialized”
This make me think that, the SqlCommand which is used in hangfire, needs the transaction of mySqlConnection object started.
This is the code i try;
SqlConnection mySqlConnection = new SqlConnection(connectionString);
mySqlConnection .BeginTransaction();
var storage = new SqlServerStorage(mySqlConnection);
var client = new BackgroundJobClient(storage);
client.Enqueue(() => Run(queueEntity.RecId));
Is there any other way for me to handle transactions?