-
Notifications
You must be signed in to change notification settings - Fork 2k
Open
Description
Type of issue
Code doesn't work
Description
The snippet about changing the default cache size is misleading and misses UseMemoryCache, which you need to make EF use your custom cache instance.
Current snippet:
public void ConfigureServices(IServiceCollection services)
{
services.AddMemoryCache(options => options.SizeLimit = 20480); // Custom size limit for EF Core caching
services.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(connectionString));
}
Correct version:
public void ConfigureServices(IServiceCollection services)
{
services.AddMemoryCache(options => options.SizeLimit = 20480); // Custom size limit for EF Core caching
services.AddDbContext<TContext>((serviceProvider, options) =>
{
options.UseMemoryCache(serviceProvider.GetRequiredService<IMemoryCache>());
///...
});
}
Page URL
Content source URL
Document Version Independent Id
e96b453f-0256-8bc9-bd21-1343f2fe246c
Platform Id
ada64a4c-83c3-6714-0fa4-d80a203f4349
Article author
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels