If for any reason you need to manage your transactions yourself, itβs much easier to use TransactionScope . It has several constructors that accept a TimeSpan parameter to set a timeout. For instance,
using(var ts = new TransactionScope(TransactionScopeOption.Required, TimeSpan.FromMinutes(1))) { using(var ctx = new MyContext()) {
I am curious why you want to set the transaction timeout, not the command timeout.
source share