Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cosmos: Allow users to pass in CosmosClientOptions to UseCosmos() #35482

Open
roji opened this issue Jan 15, 2025 · 0 comments
Open

Cosmos: Allow users to pass in CosmosClientOptions to UseCosmos() #35482

roji opened this issue Jan 15, 2025 · 0 comments

Comments

@roji
Copy link
Member

roji commented Jan 15, 2025

Cosmos supports passing configuration to CosmosClient via CosmosClientOptions. EF doesn't currently allow to be passed directly by the user - we instead wrap those options, exposing EF mechanisms for specifying them instead. Unsurprisingly, new options have been introduced on CosmosClientOptions which we haven't kept up with; there's general consensus in the team this isn't a great story, and that some mechanism for passing CosmosClientOptions to UseCosmos() makes sense.

The main reason EF wraps CosmosClientOptions options is that CosmosClientOptions doesn't currently support value equality, and so cannot be compared in EF's internal service provider cache - see #35481 for a more general discussion of that problem (which also affects other providers). One way forward on that is Azure/azure-cosmos-dotnet-v3#4965, which would add value semantics to CosmosClientOptions, and so we could use our normal caching mechanism as usual (but that wouldn't help the general problem in #35481, e.g. for other providers).

Even if that isn't implemented, we could still add an API accepting CosmosClientOptions, and do one of two things:

  1. Simply ignore CosmosClientOptions in the options caching. As long as users don't vary the configuration (the vast majority?), everything works fine. If users do vary, later options get ignored and the first CosmosClient gets picked up (bad).
  2. Use reference identity for the caching. Everyone using AddDbContext/OnConfiguring will immediately get "too many service providers" if they use AddDbContext/OnConfiguring (since the instance is always different).

Once we introduce such a mechanism, we could also optionally obsolete the current wrapping options, pointing users to the new API instead.

/cc @Pilchie @NinoFloris

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant