EF Framework Multiple Table save

Source: Internet
Author: User

EF's savechanges do have transactional features, and this 3-story link contains:
Versions of the Entity Framework, whenever you execute SaveChanges () to insert, UPDATE or delete on the database the F Ramework would wrap that operation in a transaction. This transaction lasts only a long enough to execute the operation and then completes. When you execute the another such operation a new transaction is started. "

But the business must also need the support of the bottom of the ADO provider, LZ's problem is the provider inside the MySQL reported errors. This can find some of the same problems, it seems that the EF transaction mode and MySQL. NET connector is not very compatible, MySQL has a report on this bug, the solution is to use TransactionScope, but I did not try.

Today we found the root of the problem. In fact, the transaction-related code here is not much error, the root cause of the transaction is invalid is the current MySQL database engine does not support the transaction!!! Look at the engine type of the table you need to use for the transaction:
SHOW TABLE STATUS from db_name WHERE name= ' table_name ';
If the value of the engine column in the result is not "InnoDB", then you will not be in the code to write the relevant transaction code in any way! The table's engine needs to be modified to a INNODB transaction to be valid, modifying the statement:
ALTER TABLE enginetest ENGINE = INNODB
I hope to be helpful to the people I see later.

http://bbs.csdn.net/topics/390982230

EF Framework Multiple Table save

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.