Intro
Entity Framework is an open source object–relational mapping framework for ADO.NET. It was originally shipped as an integral part of Dotnet Framework, however starting with Entity Framework version 6.0 it has been delivered separately from the .NET Framework.
16 Steps Guide To Improve EF Core Performance
- Use projections - Use Async Methods
Use compiled queries in EF
-
Avoid non cancellable queries - Include only necessary tables - Select desired rows ( obviously ) For bulk processing use chunks
-
Use Any method of LINQ for filters
-
Use DbContextPool with DB contexts
For multiple filters use IQueryable
Don’t use raw SQL queries everywhere - Use AsNo Tracking for readonly operations - Use Pagination , don’t bring all data once Use TryGetNonEnunerated Count for Count - Avoid using SQL Queries in for each loop . - Reduce round trips to db by calling SaveChangesAsync one time for bulk operations