neisbut / Npgsql.Bulk

Helper for performing COPY (bulk insert and update) operation easily, using Entity Framework + Npgsql.
MIT License
107 stars 44 forks source link

Double insert when SaveChanges after BulkInsert #77

Open ealeykin opened 2 years ago

ealeykin commented 2 years ago

var uploader = new BulkUploader(context);
uploader.Insert(items); // first insert
context.SaveChanges(); // will insert items one more time

The snippet above shows minimal steps to reproduce, basically after bulk insert the state of entries remains Added and subsequent call to SaveChanges will apply all the changes (entries Added) one more time.

dima-zhemkov commented 2 years ago

I've got the same issue on 0.10.3. EF Core 3.1.7

UPD: It works when disableEntitiesTracking is set to true. Why do we need this parameter? In what cases it must be set to false?