EnlistTransaction should check whether the given transaction is the same as the one it is already enlisted in and do nothing in that case. That would match the behaviour of MySql.Data and other providers.
Test to reproduce:
[Fact]
public void EnlistingInTheSameAmbientTransactionMultipleTimesDoesNotThrow()
{
using (new TransactionScope())
{
using (var connection = new MySqlConnection("AutoEnlist=false"))
{
connection.Open();
connection.EnlistTransaction(Transaction.Current);
connection.EnlistTransaction(Transaction.Current);
}
}
}
EnlistTransaction should check whether the given transaction is the same as the one it is already enlisted in and do nothing in that case. That would match the behaviour of MySql.Data and other providers.
Test to reproduce: