Batch Updates EF Code First

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
erdiay
Posts: 1
Joined: Mon 26 Dec 2011 10:18

Batch Updates EF Code First

Post by erdiay » Mon 26 Dec 2011 10:46

Hi,

We are using EF 4.1 and dotConnect for Oracle 6.5.
In out project, we need to execute large number of insert operations(about 30.000) and it takes about 30min to execute.
We've already enabled BatchUpdates, disabled AutoDetectChangesEnabled but nothing changed.

Our model is like that:

Code: Select all

public abstract class BatchOrder
    {
        //..
        public virtual ICollection Orders { get; set; }
        //..
    }
and the usage is:

Code: Select all

Repository.Add(batchOrder);
var sw = Stopwatch.StartNew();
UnitOfWork.Commit();
Is BatchUpdates not compatible with inner collections?
What I mean is, in our case batchorder has about 30.000 orders and when we add batchorder to repository, 30.000 prepare&execute commands are executed on the db. What I expected is that, there would be a single prepare&execute statement for 30.000 order.
Any help will be appreciated.

Shalex
Devart Team
Posts: 8079
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Thu 29 Dec 2011 13:19

The limitations of Batch Updates are listed here: http://www.devart.com/blogs/dotconnect/ ... imitations.
1. Please take into account that entities should not have StoreGenerated=Identity/Computed columns. Probably, your Order class has Identity primary key (Code-First approach). Identity also can be set implicitly by System.Data.Entity.ModelConfiguration.Conventions.StoreGeneratedIdentityKeyConvention (by default, it is included into DbModelBuilder's collection).
2. Usage of TransactionScope turns off Batch Updates.
3. Default value of BatchSize is 30. You can increase the size.

Post Reply