InternetException

Entity Framework

Entity Framework · 6 posts (all categories)

Entity Framework: Change Tracking

· 31 words · ~1 min read · in .NET, Entity Framework, interview

tracked entities are saved during SaveChanges() call entities being tracked when they are: returned from DB attached to context added as subentity tracking can be disabled (AsNoTracking() i.e.) Further read: https://learn.microsoft.com/en-us/ef/core/change-tracking/

Entity Framework: eager and lazy loading

· 71 words · ~1 min read · in .NET, Entity Framework, interview

  • lazy loading:

    • delaying load of data until we specifically request for it
    • i.e. accessing customer.Address loads Address of a customer in the background via separate SQL query
    • property needs to be public, virtual
    • context.Configuration.ProxyCreationEnabled should be true
    • context.Configuration.LazyLoadingEnabled should be true
    • to disable lazy loading completely Context.Configuration.LazyLoadingEnabled = false;
  • eager loading

    • opposite of lazy loading
    • loads related entities as part of the query
    • done via .Include() query

Further read:

Read the whole thing →

Entity Framework and Base Entity class

· 906 words · ~4 min read · updated · in .NET, Entity Framework

#AutoMapper

Entity Framework does great job with taking care of entities changes and entities collection internally. And its uses almost plain POCO objects. Almost because collections of dependents data like in 1 to many tables relationship needs virtual keyword. Its understandable since EF needs to track what happens to collection. For instance lets have 2 tables: Customer and dependent Order.

Read the whole thing →

Ninject and Entity Framework

· 730 words · ~3 min read · updated · in .NET, C#, Entity Framework

#Ninject

Last time I wrote about problem with testing Entity Framework in Visual Studio 2012. During working on this project I also encounter problems with configuration of Ninject to allow injecting Entity Framework classes from its Patterns extension. To be frankly this was not much a problem then lack of documentation. I just was forced to experiment with Ninject and new-thing-for-me Entity Framework Patterns extension.

Read the whole thing →

Entity Framework Patterns extension and Unit Test in Visual Studio 2012

· 646 words · ~3 min read · updated · in Entity Framework, Visual Studio

#Unit tests #reflection #NuGet #Ninject

Yesterday I was trying to make work simple test class in VS2012. I did not know what was wrong exactly. It was first project when I tried to glue together Entity Framework with repository pattern and Ninject as IoC container. Because of the fact that this was first time for solution like that I was sure that it is me, or rather source of my problem was indeed my code. But let’s not skip ahead.

Read the whole thing →