Loading user information from Channel 9

Something went wrong getting user information from Channel 9

Latest Achievement:

Loading user information from MSDN

Something went wrong getting user information from MSDN

Visual Studio Achievements

Latest Achievement:

Loading Visual Studio Achievements

Something went wrong getting the Visual Studio Achievements

Entity Framework Tips and Tricks

55 minutes, 5 seconds


Right click “Save as…”

In this show, Robert is joined by Julie Lerman, the author of several highly acclaimed Entity Framework books. Julie shares a number of Entity Framework tips and tricks including:

  • Overriding the DBContext SaveChanges method [02:00]
  • EntityFramework Power Tools [19:00]
  • Configuring 1:1 Relationships [27:00]
  • How to Avoid Accidentally Adding Data [34:30]
  • Debugging [47:15]

While taping this, Robert's microphone malfunctioned. Fortunately, Julie's microphone picked him up. That is why his sound is not up to the normal quality and level.


Follow the discussion

  • Oops, something didn't work.

    Getting subscription
    Subscribe to this conversation
  • WOW!! Robert you delivered an awesome DIAMOND!!!  Julie Lerman has made my learning curve of Entity Framework SO MUCH SHORTER!!  Thank you Julie and please come often!!!  LOVE YOUR PLURALSIGHT COURSES!!

  • haha Alex! Can I hire you as my publicist? Smiley

  • Anytime!  I am super affordable...all I ask for is 5 Entity Framework answers to any future problems I may come across in 1 year.   Cool

  • I  have asked julie why didn't use virtual keyword on navigation properties in her example and she replied me the keyword "virtual" must be used on navigation properties only if dbcontext is available for lazy loading. Thanks for your answer julie!

  • Thanks Kemal! It was nice meeting you on twitter! Just to clarify for newbies: lazy loading is optional with EF. It requires a combination of telling the DbContext instance that you want to enable lazy loading (DbContext.Configuration.LazyLoadingEnabled) which you can do as needed or even in the constructor of the context) PLUS any navigation properties that should take advantage of lazy loading need to be marked virtual. So if the property is marked virtual, but you don't have LL enabled, it won't work. (and the other way around). Since I had no need for lazy loading, I didn't bother with "virtual" in my examples. (P.S. in VB that's Overridable Smiley )

  • It is my pleasure to help people =] I have couple of questions again. I will be glad if you enlighten me Smiley

    1- I'm agree with improving EF performance by using AsNoTracking as well as setting ProxyCreationEnabled = false.  As you know with EF5 there is a lot performance improvements and its more of that on EF6 with SQL query optimization (I voted on it btw Tongue Out). I think you are alike using lazy-loading and using AsNoTracking while retrieving lists or something Smiley. Doesn't it reduce performance if you have like 1.000.000 rows? Because it will retrieve all the objects and cache in memory unless dbcontext is disposed.

    2- Relating with the first question, assume we return no tracked objects, isn't it problematic for their navigation properties if our business logic is based on parallel transactions? Or do you think that it is up to design? 

    3- What if there is a nested TransactionScope in a method? Does it reduce perfomance or wrap into a one big TransactionScope? 


  • Hey Kemal,

    re #1, I can't get past "1million rows". I would never dream about pulling that much data across teh wire into an application. The point of using notracking is to use EF to retrieve data that is read-only. No need to waste resources asking EF to track that data. I recall some  unexecpted (to me) but expected to EF behavior where it can lazy load from objects that were queried with no tracking. I cannot remember...I'd have to go look in one of my books (yes, I have to do taht) or just try it again.

    re#2: dependent on what that behavior is about notracked and lazy or possibly exlicitly loaded objects that I just mentioned.

    re 3... Acch...that one I cannot answer off the top of my head. It would take some experimenting to answer. That's how I have to learn. If you have some time to do some testing on that one, I'd be interested in your discoveries. Sorry I just had a brief moment to stop by and those last two questions take a lot more thought.

  • MagicAndre1981Magic​Andre1981 xperf addicted

    EntityFramework Power Tools [19:00]

    I work different. I use an empty EDMX file, reverse engineer the DB into the model and use a Fluent API T4 template to generate the DbContext and POCOs (all in different projects) so that the POCOs have no reference to EF. Here I can change something in the Designer and let the T4 template generate the updated files for me. The only really nice feature of the Power Tools is to generate the views for faster queries.

  • Great post, not nearly enough good ratings and comments. Keep it up guys.

  • DesmondDesmond

    Hi julielerman,

    Good explanation and very good presentation. I would like to know suppose if we have a table with large data would all the data be loaded into the memory. Using LINQ and selecting the data based on the query criteria would it load only the relevant data into the memory.

  • Good job!

  • very good tips. And did not know about Plural Sight.  Going to that right now.

    Priceless books, I have them all.

  • Great respect for this lady. I have benefited from her courses and articles too much.

Remove this comment

Remove this thread


Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.