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 8897217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:16:56+00:00 2026-06-15T00:16:56+00:00

No, the answer to my second question is not the winter. Preface: I’ve been

  • 0

No, the answer to my second question is not the winter.

Preface:

I’ve been doing a lot of research on Entity Framework recently and something that keeps bothering me is its performance when the queries are not warmed-up, so called cold queries.

I went through the performance considerations article for Entity Framework 5.0. The authors introduced the concept of Warm and Cold queries and how they differ, which I also noticed myself without knowing of their existence. Here it’s probably worth to mention I only have six months of experience behind my back.

Now I know what topics I can research into additionally if I want to understand the framework better in terms of performance. Unfortunately most of the information on the Internet is outdated or bloated with subjectivity, hence my inability to find any additional information on the Warm vs Cold queries topic.

Basically what I’ve noticed so far is that whenever I have to recompile or the recycling hits, my initial queries are getting very slow. Any subsequent data read is fast (subjective), as expected.

We’ll be migrating to Windows Server 2012, IIS8 and SQL Server 2012 and as a Junior I actually won myself the opportunity to test them before the rest. I’m very happy they introduced a warming-up module that will get my application ready for that first request. However, I’m not sure how to proceed with warming up my Entity Framework.

What I already know is worth doing:

  • Generate my Views in advance as suggested.
  • Eventually move my models into a separate assembly.

What I consider doing, by going with common sense, probably wrong approach:

  • Doing dummy data reads at Application Start in order to warm things
    up, generate and validate the models.

Questions:

  • What would be the best approach to have high availability on my Entity Framework at anytime?
  • In what cases does the Entity Framework gets “cold” again? (Recompilation, Recycling, IIS Restart etc.)
  • 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-15T00:16:57+00:00Added an answer on June 15, 2026 at 12:16 am
    • What would be the best approach to have high availability on my Entity Framework at anytime?

    You can go for a mix of pregenerated views and static compiled queries.

    Static CompiledQuerys are good because they’re quick and easy to write and help increase performance. However with EF5 it isn’t necessary to compile all your queries since EF will auto-compile queries itself. The only problem is that these queries can get lost when the cache is swept. So you still want to hold references to your own compiled queries for those that are occurring only very rare, but that are expensive. If you put those queries into static classes they will be compiled when they’re first required. This may be too late for some queries, so you may want to force compilation of these queries during application startup.

    Pregenerating views is the other possibility as you mention. Especially, for those queries that take very long to compile and that don’t change. That way you move the performance overhead from runtime to compile time. Also this won’t introduce any lag. But of course this change goes through to the database, so it’s not so easy to deal with. Code is more flexible.

    Do not use a lot of TPT inheritance (that’s a general performance issue in EF). Neither build your inheritance hierarchies too deep nor too wide. Only 2-3 properties specific to some class may not be enough to require an own type, but could be handled as optional (nullable) properties to an existing type.

    Don’t hold on to a single context for a long time. Each context instance has its own first level cache which slows down the performance as it grows larger. Context creation is cheap, but the state management inside the cached entities of the context may become expensive. The other caches (query plan and metadata) are shared between contexts and will die together with the AppDomain.

    All in all you should make sure to allocate contexts frequently and use them only for a short time, that you can start your application quickly, that you compile queries that are rarely used and provide pregenerated views for queries that are performance critical and often used.

    • In what cases does the Entity Framework gets “cold” again? (Recompilation, Recycling, IIS Restart etc.)

    Basically, every time you lose your AppDomain. IIS performs restarts every 29 hours, so you can never guarantee that you’ll have your instances around. Also after some time without activity the AppDomain is also shut down. You should attempt to come up quickly again. Maybe you can do some of the initialization asynchronously (but beware of multi-threading issues). You can use scheduled tasks that call dummy pages in your application during times when there are no requests to prevent the AppDomain from dying, but it will eventually.

    I also assume when you change your config file or change the assemblies there’s going to be a restart.

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

Sidebar

Related Questions

Referring second answer to question: How to convert from ASCII to Hex and vice
I don't really understand the second question, is my answer to the second question
Hi I didn't get an answer before so second try... I want to control
The answer to a question on multiple-value elements in a config file (which exactly
I think I'm missing something obvious and would appreciate an answer. I have a
This is my second question, and I’m hoping to resolve an issue that I
This is my second question about this topic, the original question can be found
I've been reading about this for a while and I'm not sure I have
For the purposes of this question, I do not have the ability to use
Referencing this question: System.Reflection.Assembly.LoadFile Locks File System.IO.File.ReadAllBytes(path) wont work since it's not a standalone

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.