Closed fsimonovskiii closed 1 month ago
Hello @fsimonovskiii,
1) you can configure ShouldPluralizeFromItemName
with dependency injection (DI) in the following way:
serviceCollection.AddDbContext<IKSqlDBContext, KSqlDBContext>(c =>
c =>
{
var setupParameters = c.UseKSqlDb(ksqlDbUrl);
setupParameters.Options.ShouldPluralizeFromItemName = false;
});
});
ReplaceHttpClient
uses the URL provided in c.UseKSqlDb(ksqlDbUrl);
by default, so you don't need to specify the baseAddress
.
If you don’t need any additional configuration for IHttpClientFactory
, using AddDbContext
will automatically set up a default HttpClientFactory
.
2) Using DI is the preferred approach. The samples use new
only for demonstration purposes.
Hi @tomasfabian
Thank you for the very quick response, it is working now. Much appreciated.
Hello,
I have two questions regarding registering through DI:
If I use the
services.ConfigureKSqlDb(config.KSqlDbUrl)
to register using dependency injection, I can see that in the context calls I am getting the topic name pluralized, most probably because I didn't specify any options and it gets the default set as true like thisHow can I go about registering both the KSqlDbContext and KSqlDbRestApiClient through DI and adding some options along the way while registering them? I saw some example in the config.md file
Does this example register both the KSqlDbContext and the KSqlDbRestApiClient to use the given ksqlDbUrl? I couldn't manage to make it work so that I can provide that I want
ShouldPluralizeFromItemName=false
. Is this possible through DI or should we make these kind of changes through new() KSqlDbContext all the time, like the following?await using var context = new KSqlDBContext(contextOptions);