Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7820637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T07:22:34+00:00 2026-06-02T07:22:34+00:00

I am developing a file storage application, and we have incorporated the FileStream type

  • 0

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.

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.

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.

Is there a way that I can tell EF not to load this byte array unless I explicitly ask for it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T07:22:36+00:00Added an answer on June 2, 2026 at 7:22 am

    Garrison,
    you can use a feature called “entity splitting” where you map two related entities to a single table. So in the first entity you would have all but the filestream property. In the 2nd entity you would have the primary key (same as in the first entity) and the filestream property. Create a one:one relationship between the entities in your model and then map both entities to the same table. Now the entity with the filestream is related and you can load or lazy load it as needed. The only downside is that it’s not a property of your main entity, so you have to navigate to the related entity and then the property.

    myEntity.MyRelatedEntity.TheFileStreamProperty

    Here’s an old blog post I wrote that shows how to do this in the EDM Designer.

    You can also achieve the same mapping with Code FIrst. Here’s an MSDN article I wrote that contains an entity splitting article. http://msdn.microsoft.com/en-us/data/hh272551

    HTH
    Julie

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are developing an application that uploads large files over Internet. File size before
I am developing a database file system .It includes a multi-directory watcher which is
I am developing a Database File System . I am using - .Net framework
I am developing my down blog engine based on file system storage, very much
I'm developing application that start page depends on file existing in isolated storage. If
im developing application for ios5.im using core data as data storage.i have to display
We are developing a file system for Windows using IFS Kit. We started to
I'm developing a file upload with JSF. The application saves three dates about the
I am developing a desktop application for pdf file management using C#. When I
I am developing an application that is writing data to a file. Lets assume

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.