The goal is simple - rollback data inserted by unit test. Here's how it goes. In the unit test, a method is called that creates a new connection and inserts some data. After that, unit test creates a new connection and tries to find what was inserted and claim it. I was hoping to wrap these two things with help TransactionScope, rather than invoking Completeand looking at the inserted data. This is not happening. Am I doing something wrong, or is there just not enough meaning?
using (new TransactionScope())
{
var target = new ....
target.DoStuffAndEndupWithDataInDb();
using (var conn = new SqlConnection(connectionString))
using (var cmd = conn.CreateCommand())
{
cmd.CommandText = "SELECT...";
conn.Open();
int count = 0;
using (var rdr = cmd.ExecuteReader())
{
...
count++;
}
Assert.AreEqual(3, count);
}
}
EDIT: I don’t think DTC was running and configured on my computer. So I started the service and tried to configure DTC, but I get this error.

source
share