Share via


CosmosDbContextOptionsBuilder Class

Definition

Allows Cosmos specific configuration to be performed on DbContextOptions.

public class CosmosDbContextOptionsBuilder
public class CosmosDbContextOptionsBuilder : Microsoft.EntityFrameworkCore.Infrastructure.ICosmosDbContextOptionsBuilderInfrastructure
type CosmosDbContextOptionsBuilder = class
type CosmosDbContextOptionsBuilder = class
    interface ICosmosDbContextOptionsBuilderInfrastructure
Public Class CosmosDbContextOptionsBuilder
Public Class CosmosDbContextOptionsBuilder
Implements ICosmosDbContextOptionsBuilderInfrastructure
Inheritance
CosmosDbContextOptionsBuilder
Implements

Remarks

Instances of this class are returned from a call to CosmosDbContextOptionsExtensions.UseCosmos{TContext} and it is not designed to be directly constructed in your application code.

See Using DbContextOptions, and Accessing Azure Cosmos DB with EF Core for more information and examples.

Constructors

CosmosDbContextOptionsBuilder(DbContextOptionsBuilder)

Initializes a new instance of the CosmosDbContextOptionsBuilder class.

Methods

ConnectionMode(ConnectionMode)

Configures the context to use the provided connection mode.

ContentResponseOnWriteEnabled(Boolean)

Sets the boolean to only return the headers and status code in the Cosmos DB response for write item operation like Create, Upsert, Patch and Replace. Setting the option to false will cause the response to have a null resource. This reduces networking and CPU load by not sending the resource back over the network and serializing it on the client.

ExecutionStrategy(Func<ExecutionStrategyDependencies,IExecutionStrategy>)

Configures the context to use the provided IExecutionStrategy.

GatewayModeMaxConnectionLimit(Int32)

Configures the maximum number of concurrent connections allowed for the target service endpoint in the Azure Cosmos DB service.

HttpClientFactory(Func<HttpClient>)

Configures the context to use a specific HttpClient factory.

IdleTcpConnectionTimeout(TimeSpan)

Configures the amount of idle time after which unused connections are closed.

LimitToEndpoint(Boolean)

Limits the operations to the provided endpoint.

MaxRequestsPerTcpConnection(Int32)

Configures the number of requests allowed simultaneously over a single TCP connection. When more requests are in flight simultaneously, the direct/TCP client will open additional connections.

MaxTcpConnectionsPerEndpoint(Int32)

Configures the maximum number of TCP connections that may be opened to each Cosmos DB back-end. Together with MaxRequestsPerTcpConnection, this setting limits the number of requests that are simultaneously sent to a single Cosmos DB back-end (MaxRequestsPerTcpConnection x MaxTcpConnectionPerEndpoint).

OpenTcpConnectionTimeout(TimeSpan)

Configures the amount of time allowed for trying to establish a connection.

PreferredRegions(IReadOnlyList<String>)

Configures the context to use the provided preferred regions for geo-replicated database accounts.

Region(String)

Configures the context to use the provided geo-replicated region.

RequestTimeout(TimeSpan)

Configures the timeout when connecting to the Azure Cosmos DB service. The number specifies the time to wait for response to come back from network peer.

WebProxy(IWebProxy)

Configures the proxy information used for web requests.

WithOption(Func<CosmosOptionsExtension,CosmosOptionsExtension>)

Sets an option by cloning the extension used to store the settings. This ensures the builder does not modify options that are already in use elsewhere.

Explicit Interface Implementations

ICosmosDbContextOptionsBuilderInfrastructure.OptionsBuilder

Gets the core options builder.

Applies to