Slow Entity Framework Core queries? Let’s speed them up!
C# value types are passed by value, so assigning one variable to another creates a copy that can change independently.
Transcript 1 topic
Skip EF change tracking
0:00Oh, please stop slowing down your Entity Framework core queries. Entity Framework tracks objects by default. It basically puts a wrapper around your customer object so that it can keep track of what properties have been changed. And it even, like, keeps a snapshot of every object as it comes out of the database so that when you eventually call the save changes on the DB context, it knows, yeah, these properties were changed on these entities, and that's what I should save back to the database. But all that takes time.
And if you're not looking to make changes to the data you're pulling out of the database, you need to look into the as no tracking extension method. It keeps Entity Framework from wrapping your object in all of its Entity Framework goo and, can speed up your queries considerably. You can technically still save those objects back to the database. It just means that you're on the hook for keeping track of changes. And that's probably not something you're gonna wanna do unless you've identified some kind of overhead with Entity Framework's default tracking via profiling or benchmarking.
Sign in to join in. Reading needs nothing.