Fast And Memory Efficient Querying in Entity Framework

Prashant
CodeX
Published in
4 min readNov 19, 2021

--

There are simple and useful ways to speed up our Entity Framework queries. We just need to know when to use what.

I was giving a presentation to a corporate client, laying out plan for a new software development. Their IT guy asked about the tech stack that we will be using for DB operations. My answer was SQL Server + Entity Framework. And he freaked out! He was concerned about the performance issues as the database was going to be huge. Since he was not a software guy, his perception was based on what he had heard from others. He wasn’t 100% wrong, but some beliefs needed to be challenged.

I assured him that Entity Framework performance isn’t as bad as he may have heard about, and a lot depends on the team/person writing the code. I explained to him some of the tips that I am going to cover in this article. After an in-depth discussion, I was able to convince him that EF (Entity Framework) has a lot more to offer than what most people know and use. The application was deployed after a few months and is running smoothly since then, with tons of data pouring in and out every day.

Here are some easy to use tips to speed up Entity Framework performance:

Use AsNoTracking()

--

--

Prashant
CodeX

Finance guy who fell in love with technology and switched careers in early 30s. Follow me: https://twitter.com/prashantio Business URL: https://runtime.one