When opening sql connection inside TransactionScope its giving "Enlisting in Ambient transactions is not supported" error. I am using ado.net in asp.net core 2 app.
        using (var ts = new TransactionScope())
        {
            try
            {
                Connection.Open();
                repository.Insert(entity);                    
                ts.Complete();
            }
            catch (Exception ex)
            {
                ts.Dispose();
            }
            finally
            {
                Connection.Close();
            }
        }
If you encounter this problem when using .Net Standard, you can add a recent reference to System.Data.SqlClient and this problem will go away.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With