In my CLI Main I need a object of my MonDbBusinessComponent class. I wrote the code below, but my object is still null. What's wrong? How to do it right?
public static IMonDbBusinessComponent monDbBusinessComponent { get; set; }
static void Main(string[] args)
{
var collection = new ServiceCollection();
collection.AddScoped<IMonDbRepository, MonDbRepository>();
ServiceProvider appServiceProvider = GetServiceProvider();
monDbBusinessComponent = appServiceProvider.GetService<IMonDbBusinessComponent>();
GetServiceProvider()is doing. It's likely null becauseIMonDbBusinessComponentisn't in the service collection.new MonDbBusinessComponent(new MonDbRepository?