Closed szavoda closed 7 years ago
changedEntityNames
contain your newly changed entity names?_cacheServiceProvider.ClearAllCachedEntries()
.In my Customer -> Phone example above, a change to the Phone entity does not show the Customer Entity in the changedEntityNames variable. I can see in the tests where you are testing for my scenario, however.
I wonder if I have set something up improperly with the entity so that the context does not recognize the relationship.
I want to avoid invalidating the entire cache. Temporarily, I am going to pass an optional parameter to SaveChanges() that will include the additional entities to invalidate the cache for.
Please provide a failing test to study it, something like the mentioned tests.
Tip: EF Core has the ignored includes
concept too.
More info
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder
.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EFQuerying;Trusted_Connection=True;")
.ConfigureWarnings(warnings => warnings.Throw(CoreEventId.IncludeIgnoredWarning));
}
Tip-2: How to find the detected cache dependencies of a query:
var debugInfo = new EFCacheDebugInfo();
var list = context.Products.Cacheable(debugInfo).ToList();
var cacheDependencies = debugInfo2.EFCacheKey.CacheDependencies;
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related problems.
Hi -
I am trying to understand a little about invalidating cache entries in my scenario. I have a Customer entity that ".Includes" several related entities such as Address and Phone during a GetCustomer operation.
I have been noticing that when I add / update a Phone record, for instance, a subsequent GetCustomer call does not reflect the new / changed records.
Is there a best practices way that you can recommend to invalidate the cache of the related object?
Thanks!
Shawn