How do I add the method AddStackExchangeRedisCache to IServiceCollection in C#?
Asked Answered
C

1

7

I have this startup.cs file that adds the different services to my application. One of the services I need to add is AddStackExchangeRedisCache but I am getting an error that says

"IServiceCollection does not contain a definition for AddStackExchangeRedisCache and no accessible extension method AddStackExchangeRedisCache accepting a first argument of type IServiceCollection could be found (are you missing a using directive or an asssembly reference?)?"

I have the following stack exchange redis refernce in my CSPROJ

    <PackageReference Include="StackExchange.Redis" Version="2.6.66" />

And the method where I am trying to add the service is as follows.

public void ConfigureServices(IServiceCollection services) {
    services.AddStackExchangeRedisCache(options =>
        {
           // some code here
        }
    }
Cyrilla answered 16/11, 2022 at 18:46 Comment(0)
G
11

Install Microsoft.Extensions.Caching.StackExchangeRedis nuget package.

Georg answered 16/11, 2022 at 18:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.