I have a appsettings.json that look like this
{
"AppName": "my-app-service",
"MyModel": {
"MyList": [{
"CountryCode": "jp"
},{
"CountryCode": "us"
}]
}
}
Now, i have a POCO file, (MyList.cs is ommited, it has a single string key countryCode)
public class MyModel
{
public IList<MyList> MyList;
}
I wish to make it so that MyModel can be injected anywhere in my code, how do I do that? I see that people do this in their setup.cs
services.Configure<MyModel>(Configuration.GetSection("MyModel"));
How ever it looks like when I use IOption<MyModel> in my code in the contructors, I just get null value. Where am I wrong?