ADO.NET Entity Framework - Pre-Generate Views -

We are using ADO.NET Entity for our ASP.NET application.

I have read that the pre-generated views improves the performance. Referred to the blog post,, I generated the views. The namespace & classes generated as

namespace Edm_EntityMappingGeneratedViews

    /// <Summary>
    /// The type contains views for EntitySets and AssociationSets that were generated at design time.
    /// </Summary>
    public sealed class ViewsForBaseEntitySets4D4A6E0AA7AF6B2298FABB4F22235831 : System.Data.Mapping.EntityViewContainer

        /// <Summary>
        /// The constructor stores the views for the extents and also the hash values generated based on the metadata and mapping closure and views
        /// </Summary>
        public ViewsForBaseEntitySets4D4A6E0AA7AF6B2298FABB4F22235831()
            this.EdmEntityContainerName = "JSEntities";

I added this to my data layer and test the performance. Couldn't see much improvement. CPU usage always goes to 20-30% utilization (response timing is good) and reduce back to 0% in 500ms - 1 sec. I think the CPU utilization goes high because of view generation every time.

I couldn't understand how the entity framework knows that this is my pre-generated view class for my model eventhough the MyModel.edmx & MyModel.Views.cs matches with filename.

Should I have to update Web.Config or App.Config to map the View class to model somewhere?

Please clarify.


I've been wondering the same thing and been doing some digging.

As far as I can tell the generated class file contains an assembly level attribute, EntityViewGenerationAttribute, which defines the class type that contains the pre-compiled view. Then, and here im only making educated guesses, at compile time the class must be loaded via reflection and in some way bound to the queries the view defines. Possibly in the ESQL cache, which would makea certain amount of sense.

Even though the view's are pre-compiled they only produce ESQL, not the actual TSQL which will be ran. However pre-compiling views does allow the execution of a query to skip the validation and ESQL generation step which should offer a slight performance gain, especially for large compilcated queries.

Need Your Help

How to make Qt(PyQt) codes runs in order?

python qt pyqt pyside python-3.4

Hello every one. I am making a desktop GUI application using PyQt5 on Windows 7.

C++ Save a string from a struct into a text file

c++ arrays string file

In my program, I have a clock timer and I need it to be saved into a char array[10] which is then implemented into my highscore function. Through my program, I already have a formatted time. Exampl...