0
Denis created
I need t configure DB context to use this library https://github.com/VahidN/EFCoreSecondLevelCacheInterceptor
How I can do that in ABP?
The code below is used to enable this interceptor
public static class MsSqlServiceCollectionExtensions
{
public static IServiceCollection AddConfiguredMsSqlDbContext(this IServiceCollection services, string connectionString)
{
services.AddDbContextPool<ApplicationDbContext>((serviceProvider, optionsBuilder) =>
optionsBuilder
.UseSqlServer(
connectionString,
sqlServerOptionsBuilder =>
{
sqlServerOptionsBuilder
.CommandTimeout((int)TimeSpan.FromMinutes(3).TotalSeconds)
.EnableRetryOnFailure()
.MigrationsAssembly(typeof(MsSqlServiceCollectionExtensions).Assembly.FullName);
})
.AddInterceptors(serviceProvider.GetRequiredService<SecondLevelCacheInterceptor>()));
return services;
}
}
ABP Version: 4.3
2 Answer(s)
-
0
Hi,
Open EntityFrameworkCoreModule class and remove
Configure<AbpDbContextOptions>...
code block.Open EntityFrameworkCoreDbMigrationsModule clsss and add following code:
context.Services.AddEFSecondLevelCache(options => options.UseMemoryCacheProvider().DisableLogging(true).UseCacheKeyPrefix("EF_")); Configure<AbpDbContextOptions>(options => { options.Configure(c => { c.UseSqlServer(builder => { builder.CommandTimeout((int) TimeSpan.FromMinutes(3).TotalSeconds) .MigrationsAssembly(typeof(QaEntityFrameworkCoreDbMigrationsModule).Assembly.FullName); }).AddInterceptors(c.ServiceProvider.GetRequiredService<SecondLevelCacheInterceptor>()); }); });
-
0
This question has been automatically marked as stale because it has not had recent activity.