The problem is with regard to best practices for handling many inserts or updates using the Microsoft Entity Framework. We have written a long-running program that pulls thousands of records back from the database, and then updates each field one by one on each of them, for our disappointment, we realized that in the updated records From Modes Each was locked for a period of time, which was not settled Objektcontekt. For example, some pseudocodes (actually not run):
using (object contact references = new object-texte ()) {var myRecords = context.CreateObjectSet & lt ; MyType & gt; (). AsQueryable (); Foreign currency (different records in my records) {record.MyField = "updated!"; Context.SaveChanges (); // - Do something really slow like calling an external web service}} The problem is that without any connection to the transaction, we need to make several updates. We were surprised to find out that calling references. The Save Change actually makes the lock on the record and does not release it until the objectcontact is disposed off. We do not want to specifically lock the records in the database because it is a high-traffic system and the program can potentially run for hours.
So the question is: What is the optimal way of updating multiple Microsoft Entity Framework 4 without having to do all those long transactions, which lock the DB? We are hoping that there is no answer to creating a new object project for every single update ...
< P> The unit reads the devised transaction isolation level by default on the top of the SQL server and at the end of the transaction SaveChanges is committed. If you have doubts about other behaviors then it should be done by the rest of your code (are you using TransactionScope ? - you have not shown it in your code) or it should be a few bugs. Apart from this, your attitude is wrong. If you want to save each record separately, you should load each record separately. EF is definitely a bad choice for these types of applications. Even if you use only single SaveChange to update all your records, it will also be available for every update. For the database, a roundtrip will do.
Comments
Post a Comment