I want to grab a value from the database in my Startup.cs file through a repository. However the service is not able to be resolved.
I understand that I need to create an instance of my repository and then access it. I have seen a similar question asked but I do not want to create a new service: .NET Core 2 - Call Repository method from Startup
In my Startup.cs I have the following:
public Startup(IConfiguration configuration, IRepository repo)
{
Configuration = configuration;
Repo = repo;
}
public IRepo Repo { get; }
public void ConfigureServices(IServiceCollection services)
{
services.AddScoped<IRepository, Repository>();
var data = Repo.GetValue();
}
When I run this though I am getting an error where it is unable to resolve the service.