Caching of navigation properties in Entity Framework Core

71 Views Asked by At

There are several solutions for caching in EF Core. But I have a question about a specific solution.

Below I have an order entity with a normal property and a navigation one. The navigation property is of type Customer which is a value which rarely changes. I want to cache all existing customers from database in memory (because there are not so much data).

public class Order
{
    prop int Id { get; set; }
    prop Customer Customer { get; set; }
}

The question is about my query. In a command query I would include Customer like this:

dbContext.Order
         .Include(c => c.Customer)
         .First();

Is there a solution that Entity Framework Core is using the cache instead a join for the included customer? Or is my query required to write special code for it?

0

There are 0 best solutions below