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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:14:28+00:00 2026-05-27T06:14:28+00:00

I have followed the Don’t Optimize Prematurely mantra and coded up my WCF Service

  • 0

I have followed the “Don’t Optimize Prematurely” mantra and coded up my WCF Service using Entity Framework.

However, I profiled the performance and Entity Framework is too slow. (My app processes 2 messages in about 1.2 seconds, where the (legacy) app that I am re-writing does 5-6 messages in the same time. (The legacy app calls sprocs for its DB Access.)

My profiling points to Entity Framework taking the bulk of the time per message.

So, what are my options?

  • Are there better ORMs out there?
    (Something that just supports normal reading and writing of objects and does it fast..)

  • Is there a way to make Entity Framework faster?
    (Note: when I say faster I mean over the long run, not the first call. (The first call is slow (15 seconds for a message), but that is not a problem. I just need it to be fast for the rest of the messages.)

  • Some mysterious 3rd option that will help me get more speed out of my service.

NOTE: Most of my DB interactions are Create and Update. I do very very little selecting and deleting.

  • 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-05-27T06:14:29+00:00Added an answer on May 27, 2026 at 6:14 am

    You should start by profiling the SQL commands actually issued by the Entity Framework. Depending on your configuration (POCO, Self-Tracking entities) there is a lot room for optimizations. You can debug the SQL commands (which shouldn’t differ between debug and release mode) using the ObjectSet<T>.ToTraceString() method. If you encounter a query that requires further optimization you can use some projections to give EF more information about what you trying to accomplish.

    Example:

    Product product = db.Products.SingleOrDefault(p => p.Id == 10);
    // executes SELECT * FROM Products WHERE Id = 10
    
    ProductDto dto = new ProductDto();
    foreach (Category category in product.Categories)
    // executes SELECT * FROM Categories WHERE ProductId = 10
    {
        dto.Categories.Add(new CategoryDto { Name = category.Name });
    }
    

    Could be replaced with:

    var query = from p in db.Products
                where p.Id == 10
                select new
                {
                    p.Name,
                    Categories = from c in p.Categories select c.Name
                };
    ProductDto dto = new ProductDto();
    foreach (var categoryName in query.Single().Categories)
    // Executes SELECT p.Id, c.Name FROM Products as p, Categories as c WHERE p.Id = 10 AND p.Id = c.ProductId
    {
        dto.Categories.Add(new CategoryDto { Name = categoryName });
    }
    

    I just typed that out of my head, so this isn’t exactly how it would be executed, but EF actually does some nice optimizations if you tell it everything you know about the query (in this case, that we will need the category-names). But this isn’t like eager-loading (db.Products.Include(“Categories”)) because projections can further reduce the amount of data to load.

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

Sidebar

Related Questions

Hi have followed this tutorial using Core plot framework http://www.switchonthecode.com/tutorials/using-core-plot-in-an-iphone-application My project compiles, but
I am trying to display a map using Rhomobile framework Rhodes I have followed
I have followed the suggestion in this question as I am using Django, I
I have followed the Local Service example provided by Google, but my Context::bindService(...) always
I have followed the instructions here [MDC - Adding Extensions using the Windows Registry],
I'm using the KnpMenuBundle in my application, and I have followed their instructions to
I have followed this guide: http://maven.apache.org/guides/plugin/guide-java-plugin-development.html I have created a maven-plugin project hello-maven-plugin with
I have followed a tutorial on how to use the youtube gdata. Populating a
I have followed the following documentation and I am having problems. I access the
I have followed this guide to install Solr in TomCat running on Windows Server

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.