A cache normally caches entities (Detached from the context) and re-uses the same result as long as the cache is not expired.
If you change the query, a new result is cached (even if it returns the same entity key) since relations could have been changed.
Here is an alternative to the cache you are currently using:
Disclaimer: I'm the owner of the project EntityFramework Plus on GitHub
EF+ Query Cache allows to cache query with tag, expiration and cache control.
Documentation: Entity Framework - Second Level Cache
EDIT: Answer comment
if data has been updated, and new information must be served up that we can remove specific entities from cache
For EF6, we have the built-in IsAutoExpireCacheEnabled
option:
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
QueryCacheManager.IsAutoExpireCacheEnabled = true;
}
For EF Core, we didn't find out how to make it happen yet.