Entity Framework Improve Performance Discover What Cause EF to be Slow
Improve Entity Framework Performance
- Is Entity Framework as slow as some people report it? Yes and no.
- Entity Framework offers great advantages over other ORM, and it's in fact pretty fast.
Problem
- It's too easy to fall into a Entity Framework performance pitfall.
- Sooner or later, many developers make some mistakes which may impact the application performance severely.
Performance Cheat Sheet
Problem | Solution |
---|---|
Add | Use AddRange Disable AutoDetectChanges Add in Batches |
Change Tracker | Track Less Entities |
DetectChanges | Disable AutoDetectChanges SaveChanges in Batches |
Eager Loading | Use AsNoTracking Use EF+ Caching Use EF+ Query Future |
Lazy Loading | Use Eager Loading |
Include | Split in multiple Include Use EF+ IncludeFilter Use EF+ IncludeOptimized |
Insert | Use EFE BulkInsert |
Query | Use AsNoTracking Use EF+ Caching Use EF+ Query Future |
SaveChanges | Use EFE Bulk Operations Use EFE BulkSaveChanges |
Recommendation
Have you read all theses articles? Great! Read them all a second or a third time if necessary.
These articles are still under development. We recommend you to subscribe to our newsletter to stay updated.
ZZZ Projects