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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:01:22+00:00 2026-06-17T06:01:22+00:00

I’ve been using LINQ to SQL for a number of years in an ASP.Net

  • 0

I’ve been using LINQ to SQL for a number of years in an ASP.Net environment. The UI and BLL tiers were separated by a web service, so lazy loading, change tracking, etc were not an option. It was nice in a way because we knew exactly what was going on in the code – we were responsible for persisting changes in the BLL (figuring out if an entity was new/updated), and there were no unexpected surprises due to some lazy-loading going on somewhere.

I’ve now moved jobs and working on a new desktop system (WPF). There are no boundaries, i.e. the UI tier will directly call the BLL (but see caveat at end). I’m looking to use EF5, but I’m a bit overwhelmed by the number of features, options, etc. that EF provides. I’m hoping I can get answer to a few questions…

  1. Should lazy loading be used across boundaries? Let’s say I wanted to display a customer and all their orders, would the UI request just the customer from the BLL, then use lazy loading to access its orders? Doing this in the UI doesn’t feel right to me. I’m assuming lazy loading is just something you would use in the BLL.

  2. I believe you can turn off lazy loading using DbContext.Configuration.LazyLoadingEnabled, but what if I wanted to use lazy loading in my BLL, but when I return the entity(s) to my UI I don’t want the UI from doing any lazy loading?

  3. What about change tracking, self-tracking entities and POCOs? What should I use when? It was never an issue for me when I worked with LINQ to SQL (it was across a web service, and ASP.Net so there was no “state”, therefore change tracking was irrelevant). I feel like I want to deactivate it all (which is what I’m used to), but I’m afraid that I’ll be missing out on some of the EF “goodness”. I think I’m worried about not being in control of persisting data.

  4. As I’ve been playing around and retrieving data using EF, I’ve noticed in some of the entity hierarchies that some of the property collections (E.g. customer.Orders) contains “proxy” entities. What are these and when would they be useful?

  5. Again I’ve noticed you can turn proxies off via DbContext.Configuration.ProxyCreationEnabled, but the documentation suggests there’s more to it than that, and some kind of relationship with the LazyLoadingEnabled setting?

  6. EF “code first” seems to be gaining in popularity. What does it give you? I’m used to designing my database in SSMS, not writing lots of classes, annotations, etc!

A final caveat – although the app’s UI tier is directly calling methods in the BLL, there’s a small chance that in the future we might want to separate them (E.g. via a web service). How would this affect design considerations, and some of the questions that I’ve raised above?

Apologies for bundling a number of questions together. If I can get answers to them all then hopefully this will be useful for others in my situation in the future.

  • 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-17T06:01:23+00:00Added an answer on June 17, 2026 at 6:01 am
    1. In my opinion lazy loading is designed to be used in the UI layer and not in the BLL. It is especially useful in data binding scenarios, for example in a master-details view. If you have a list of customers in your UI and by clicking on a customer the user can display the customer’s orders those orders could be loaded by lazy loading. Since you don’t know in advance which customers the user will click you would be forced otherwise to load all orders of all customers up-front if you don’t want to use lazy loading (or implement your own event-driven child loading mechanism). This would create unnecessary overhead.

      On the other side I can’t see why lazy loading in the BLL would be interesting. Normally you know which data have to loaded to perform a specific business logic. When you know it you can use eager or explicit loading. It’s one or two lines more code to write than just accessing a navigation property and rely on lazy loading but with eager and explicit loading it is clear what your code does and when the database gets accessed.

      Keep in mind of course that lazy loading needs a context that hasn’t been disposed so you must design the BLL in a way that the context lives as long as your UI (or parts of the UI) are used.

    2. If you don’t want lazy loading in the UI layer turn it off and use eager and explicit loading in the BLL. You cannot turn off lazy loading once you have loaded entities with lazy loading enabled.

    3. Self-tracking entities are deprecated or at least the EF team suggests to not use them anymore in new projects (second reference: http://msdn.microsoft.com/en-us/data/jj613668). They also suggest to not use EntityObject derived entities anymore. So, POCOs are definitely the way to go.

      Change tracking itself is a core feature of EF and available also for POCOs in two different forms: As “snapshot based” change tracking and with change tracking proxies. The default is snapshot based change tracking. Change tracking proxies can be used to improve performance in certain scenarios – especially when thousands of entities are involved and need to be updated in a single context. More about change tracking proxies is here: http://blog.oneunicorn.com/2011/12/05/should-you-use-entity-framework-change-tracking-proxies/

    4. EF creates proxies from POCO entities if lazy loading or dynamic change tracking is enabled. They are dynamic objects derived from your entity classes and needed to make lazy loading and dynamic change tracking (= not snapshot based) possible.

    5. Setting ProxyCreationEnabled to false disables any proxy creation – for dynamic change tracking and for lazy loading as well. The setting of LazyLoadingEnabled doesn’t matter anymore if proxy creation is off. More details are here: https://stackoverflow.com/a/7112470/270591

    6. If you feel more comfortable with a database first approach then use it. It is equally well supported as code-first or model-first and – as an EDMX based approach – has even a few more advanced features that code-first does not have. More details about the different strategies are here: https://stackoverflow.com/a/5446587/270591

    …although the app’s UI tier is directly calling methods in the BLL,
    there’s a small chance that in the future we might want to separate
    them (E.g. via a web service). How would this affect design
    considerations, and some of the questions that I’ve raised above?

    You would not be able to use lazy loading in the UI layer anymore because you cannot pass a context instance through a web service boundary. Lazy loading will become as useless as it is in web applications where the UI is the (disconnected) remote browser. You will also lose the comfort of change tracking attached entities. Building change sets for disconnected entities and object graphs is more difficult than leveraging change tracking of connected entities. So, this “small chance” will possibly have a deep impact on the whole application design.

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

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am using JSon response to parse title,date content and thumbnail images and place
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
I am using the SimpleRSS gem to parse a WordPress RSS feed. The only
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm interested in microtypography issues on the web. I want a tool to fix:
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build

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.