Eager Loading: use the Include method like
db.books.Include(b=>b.Related_entity);
Lazy Loading: EF automatically loads the related entity when navigation property is referenced. To enable lazy loading, make the navigation property virtual.
public virtual Author Author{get;set;}
Problem of Circular Reference during Serializing models.
When both entities have navigation property with each other, it created a problem when we serialize the models. It creates a circular object graph.
Solution:
We need to use DTO and load all data in them before returning it.
db.books.Include(b=>b.Related_entity);
Lazy Loading: EF automatically loads the related entity when navigation property is referenced. To enable lazy loading, make the navigation property virtual.
public virtual Author Author{get;set;}
Problem of Circular Reference during Serializing models.
When both entities have navigation property with each other, it created a problem when we serialize the models. It creates a circular object graph.
Solution:
We need to use DTO and load all data in them before returning it.
No comments:
Post a Comment