News for hackers. Stuff that matters.
Re:Understanding the .NET ecosystem: The evolution of .NET i... by NicoJuicy on Tuesday March 21, 2023 @07:14PM (#35254126)
For performance, .NoTracking() and not calling .SaveChanges() on every loop already does wonders.

I usually call .SaveChanges() when i % 20 == 0

Re:Understanding the .NET ecosystem: The evolution of .NET i... by magicalhippo on Tuesday March 21, 2023 @07:39PM (#35254434)
We'll need tracking (if I understand correctly, we need previous values). When calling SaveChanges often, how do you handle rollback in case something fails?
Re:Understanding the .NET ecosystem: The evolution of .NET i... by fabian2k on Tuesday March 21, 2023 @07:43PM (#35254481)
Either wrap everything into a transaction or just call SaveChangesAsync only once. The exact behaviour depends on the database here, under the hood this uses database transactions.
Re:Understanding the .NET ecosystem: The evolution of .NET i... by NicoJuicy on Wednesday March 22, 2023 @01:28AM (#35257182)
You can use .NoTracking() and an SQL query for bulk changes ( and minor changes). Eg. Updating one column.

Works faster than with .Tracking. The SQL script runs in your transaction, so rollback runs as usual.

The i%20==0 condition with .SaveChanges() is used with .Tracking(), yes.