Bug #53143 Transactions not working with .Net Entity framework connector
Submitted: 25 Apr 2010 16:13 Modified: 24 Sep 2010 9:35
Reporter: Kaleem Khan Email Updates:
Status: No Feedback Impact on me:
None 
Category:Connector / NET Severity:S2 (Serious)
Version:6.0.5 OS:Any
Assigned to: Assigned Account CPU Architecture:Any
Tags: Entity Framework transactions

[25 Apr 2010 16:13] Kaleem Khan
Description:
I was trying to create a distributed transaction for example insert row into mySQL table and update to active directory or for simplicity I tested with insert into mySQL table and sending an email. 

After calling entity framework SaveChanges() method (immidiately observed a row inserted in mySQL table ) I made smtp client throw and exception upon sending email then I observed that the row insert was not rolled back. Infact it was committed immidiately after call to SaveChanges().

Same test with SQL Server was successful. Upon calling SaveChanges() during debugging, I tired to query table in SQL Server Management Studio and query execution was pending due to transaction lock and then stepping forward in debugger exception was thrown on mail.Send(). I stoppped the the debugger, the lock on table was released and immidiately my query on SQL Server table retuned and there was no new row inserted.  

How to repeat:
Assignment_Tickets tickets = new Assignment_Tickets();
            tickets.Ticket_Time_Stamp = DateTime.Now;
            tickets.Ticket_Opened = false;      

            using (System.Transactions.TransactionScope ts = new System.Transactions.TransactionScope())
            {
                db.AddToAssignment_Tickets(tickets);

                db.SaveChanges(false);

                MailMessage message = new MailMessage();                
                message.Subject = "Account Assignment trial message";
                message.Body = "";
                
                System.Net.Mail.SmtpClient client = new  System.Net.Mail.SmtpClient("");
                
                // will throw exceotion as no relay server defined in SmtpClient
                client.Send(message);

                ts.Complete();
[25 Apr 2010 16:14] Kaleem Khan
Changing severity level as this has impdiments in production environment.
[26 Apr 2010 0:55] Kaleem Khan
Mentioned connector ver.
[26 Apr 2010 11:43] Tonci Grgin
Hi Kaleem and thanks for your report.

Can you please try newer c/NET versions (6.2 or even 6.3) and see if they work ok for you. 6.0 is way too old and EF support there is quite rudimentary.
[26 Apr 2010 13:21] Kaleem Khan
Hi Tonci,

I tested with 6.2.3 and 6.3.1 this morning and none of them is reflecting the desired behaviour.
[5 May 2010 12:34] Tonci Grgin
Kaleem, I will require an entire test project from you and I want you to check what is the status of autocommit variable on your MySQL server.
[5 Jun 2010 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[24 Aug 2010 9:35] Tonci Grgin
Probably just AUTOCOMMIT set to 1 but I still need confirmation from Kaleem.
[24 Sep 2010 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".