Skip to content

Dependency Injection and Singleton Pattern with Cosmos Provider #1974

@thisisbrianstewart

Description

@thisisbrianstewart

Is there guidance on how to use EF Core Cosmos provider with Dependency Injection? Does the cosmos DbContext use the singleton pattern?

Of particular interest is around ensuring singleton pattern and the overarching best practice from the Cosmos docs to use a single static client for the lifetime of web apps. My use-case is to use the EF Core Cosmos provider in an Azure Function, and as such, since both Functions and Cosmos docs strongly advise static clients, I am curious how to properly use DI with the Cosmos provider to ensure a single static client.


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions