title: How do I prevent Entity Framework from loading a FileStream column into a byte array?
body: <p>I am developing a file storage application, and we have incorporated the FileStream type in our database.  The system is expected to support large files.  One portion of the application allows for bulk uploads of multiple documents.  These documents then have to be linked to other entities within the system.</p>
  
  <p>One page is designed to show unlinked documents, to allow a user to link the documents one at a time to entities.  After doing some load testing of the upload process, we found that the memory footprint of the ASP.NET worker process spiked to over a GB when loading this Unlinked Documents page.</p>
  
  <p>After investigation, it seems that Entity Framework is loading the entire document row entity (including the FileStream, converted to a byte array) for hundreds of unlinked documents.  In my repository class, I don't save this byte array when converting to a Model, but by then it's too late.  EF has spent the time and the memory to allocate the byte array into the Repository class representation.</p>
  
  <p>Is there a way that I can tell EF not to load this byte array unless I explicitly ask for it?  </p>