- 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:
SaveChanges()
callAsNoTracking()
i.e.)Further read:
customer.Address
loads Address of a customer in the background via separate SQL queryContext.Configuration.LazyLoadingEnabled = false;
.Include()
queryFurther read:
https://www.entityframeworktutorial.net/lazyloading-in-entity-framework.aspx
https://www.entityframeworktutorial.net/eager-loading-in-entity-framework.aspx
In my last post I explained why is useful to add base entity class in EF. Today I will write how with use of this base class an AutoMapped map collection of data objects (i.e. DTOs to existing collection of entities). Continue reading “Mapping collection of entities in EF with 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.
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. Continue reading “Ninject and Entity Framework”