Huge Memory Issue in Entity framework Load Method

Indudhar Gowda 426 Reputation points
2022-05-04T17:07:33.027+00:00
 this.Context.TestPRepetitions.Where(tp => sampleCodes.Contains(tp.SampleCode))  
                .Include(tp => tp.ReportableResults)  
                .Load();  
  
 this.Context.Recognitions.Where(rec => reportableResultIds.Contains(rec.ReportableResultId)).Load();  

Recognitions Table has 6352014 Rows

@AgaveJoe this what the Actual Method Does...

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,395 questions
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,757 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,277 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 56,686 Reputation points
    2022-05-04T21:21:01.43+00:00

    Don’t use Load(). It’s whole point is to load all the rows into memory, and uses lots of memory.