You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am bulk inserting data into a sql server db. I add a few hundred records at a time, call SaveChanges, and dispose of the context. Then create a new Context to add the next few hundred.
After disposing and creating the new context, the change tracker tracks 0 entries, as expected. Upon adding the next first object to the new context with Update, the context picks up the previously added entries, and tracks them with a state of unchanged. Since I'm adding tens of thousands of records, after adding a few thousand, the dbcontext slows down significantly, as it is tracking lots of unchanged records.
I have AutoDetectChangesEnabled set to false, and am using auto-generated Ids.
Steps to reproduce
Create DbContext
add items with Update
savechanges
dispose of context
note that change tracker is not tracking anything
add a new item with Update
check change tracker, see that previously added entries are there.
I've seen this comment here: #6737 (comment) that mentions the garbage collector needing to run to release entries from memory. But is this relevant with a new context tracking old entries?
To get around this issue I've been manually detaching the entries before disposing. Which does solve it, but isn't ideal as acknowledged in this thread: #10125 (comment)
I realise that my usage isn't common and the issue isn't really blocking but bringing it up in case it's a symptom of a bigger bug somewhere.
Further technical details
EF Core version: 3.0.0-preview9.19423.6
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET Core 3.0
Operating system: Windows 10 64 bit
IDE: Visual Studio 2019 16.3 preview 3
The text was updated successfully, but these errors were encountered:
EF Team Triage: Closing this issue as the requested additional details have not been provided and we have been unable to reproduce it.
BTW this is a canned response and may have info or details that do not directly apply to this particular issue. While we'd like to spend the time to uniquely address every incoming issue, we get a lot traffic on the EF projects and that is not practical. To ensure we maximize the time we have to work on fixing bugs, implementing new features, etc. we use canned responses for common triage decisions.
I am bulk inserting data into a sql server db. I add a few hundred records at a time, call SaveChanges, and dispose of the context. Then create a new Context to add the next few hundred.
After disposing and creating the new context, the change tracker tracks 0 entries, as expected. Upon adding the next first object to the new context with Update, the context picks up the previously added entries, and tracks them with a state of unchanged. Since I'm adding tens of thousands of records, after adding a few thousand, the dbcontext slows down significantly, as it is tracking lots of unchanged records.
I have AutoDetectChangesEnabled set to false, and am using auto-generated Ids.
Steps to reproduce
How I'm saving with/disposing of the context.
Notes
I've seen this comment here: #6737 (comment) that mentions the garbage collector needing to run to release entries from memory. But is this relevant with a new context tracking old entries?
To get around this issue I've been manually detaching the entries before disposing. Which does solve it, but isn't ideal as acknowledged in this thread: #10125 (comment)
I realise that my usage isn't common and the issue isn't really blocking but bringing it up in case it's a symptom of a bigger bug somewhere.
Further technical details
EF Core version: 3.0.0-preview9.19423.6
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET Core 3.0
Operating system: Windows 10 64 bit
IDE: Visual Studio 2019 16.3 preview 3
The text was updated successfully, but these errors were encountered: