CosmosDbContextOptionsExtensions.UseCosmos Method

Definition

Overloads

UseCosmos(DbContextOptionsBuilder, Action<CosmosDbContextOptionsBuilder>)

Configures the context to connect to an Azure Cosmos database. The connection details need to be specified in a separate call.

UseCosmos(DbContextOptionsBuilder, String, String, Action<CosmosDbContextOptionsBuilder>)

Configures the context to connect to an Azure Cosmos database.

UseCosmos(DbContextOptionsBuilder, String, TokenCredential, String, Action<CosmosDbContextOptionsBuilder>)

Configures the context to connect to an Azure Cosmos database.

UseCosmos(DbContextOptionsBuilder, String, String, String, Action<CosmosDbContextOptionsBuilder>)

Configures the context to connect to an Azure Cosmos database.

UseCosmos<TContext>(DbContextOptionsBuilder<TContext>, Action<CosmosDbContextOptionsBuilder>)

Configures the context to connect to an Azure Cosmos database. The connection details need to be specified in a separate call.

UseCosmos<TContext>(DbContextOptionsBuilder<TContext>, String, String, Action<CosmosDbContextOptionsBuilder>)

Configures the context to connect to an Azure Cosmos database.

UseCosmos<TContext>(DbContextOptionsBuilder<TContext>, String, TokenCredential, String, Action<CosmosDbContextOptionsBuilder>)

Configures the context to connect to an Azure Cosmos database.

UseCosmos<TContext>(DbContextOptionsBuilder<TContext>, String, String, String, Action<CosmosDbContextOptionsBuilder>)

Configures the context to connect to an Azure Cosmos database.

UseCosmos(DbContextOptionsBuilder, Action<CosmosDbContextOptionsBuilder>)

Source:
CosmosDbContextOptionsExtensions.cs

Configures the context to connect to an Azure Cosmos database. The connection details need to be specified in a separate call.

C#
public static Microsoft.EntityFrameworkCore.DbContextOptionsBuilder UseCosmos (this Microsoft.EntityFrameworkCore.DbContextOptionsBuilder optionsBuilder, Action<Microsoft.EntityFrameworkCore.Infrastructure.CosmosDbContextOptionsBuilder> cosmosOptionsAction);

Parameters

optionsBuilder
DbContextOptionsBuilder

The builder being used to configure the context.

cosmosOptionsAction
Action<CosmosDbContextOptionsBuilder>

An action to allow Cosmos-specific configuration.

Returns

The options builder so that further configuration can be chained.

Remarks

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

Applies to

Entity Framework Core 9.0
Product Versions
Entity Framework Core 9.0

UseCosmos(DbContextOptionsBuilder, String, String, Action<CosmosDbContextOptionsBuilder>)

Source:
CosmosDbContextOptionsExtensions.cs
Source:
CosmosDbContextOptionsExtensions.cs
Source:
CosmosDbContextOptionsExtensions.cs
Source:
CosmosDbContextOptionsExtensions.cs
Source:
CosmosDbContextOptionsExtensions.cs

Configures the context to connect to an Azure Cosmos database.

C#
public static Microsoft.EntityFrameworkCore.DbContextOptionsBuilder UseCosmos (this Microsoft.EntityFrameworkCore.DbContextOptionsBuilder optionsBuilder, string connectionString, string databaseName, Action<Microsoft.EntityFrameworkCore.Infrastructure.CosmosDbContextOptionsBuilder> cosmosOptionsAction = default);
C#
public static Microsoft.EntityFrameworkCore.DbContextOptionsBuilder UseCosmos (this Microsoft.EntityFrameworkCore.DbContextOptionsBuilder optionsBuilder, string connectionString, string databaseName, Action<Microsoft.EntityFrameworkCore.Infrastructure.CosmosDbContextOptionsBuilder>? cosmosOptionsAction = default);

Parameters

optionsBuilder
DbContextOptionsBuilder

The builder being used to configure the context.

connectionString
String

The connection string of the database to connect to.

databaseName
String

The database name.

cosmosOptionsAction
Action<CosmosDbContextOptionsBuilder>

An optional action to allow additional Cosmos-specific configuration.

Returns

The options builder so that further configuration can be chained.

Remarks

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

Applies to

Entity Framework Core 9.0 and other versions
Product Versions
Entity Framework Core 5.0, 6.0, 7.0, 8.0, 9.0

UseCosmos(DbContextOptionsBuilder, String, TokenCredential, String, Action<CosmosDbContextOptionsBuilder>)

Source:
CosmosDbContextOptionsExtensions.cs
Source:
CosmosDbContextOptionsExtensions.cs
Source:
CosmosDbContextOptionsExtensions.cs

Configures the context to connect to an Azure Cosmos database.

C#
public static Microsoft.EntityFrameworkCore.DbContextOptionsBuilder UseCosmos (this Microsoft.EntityFrameworkCore.DbContextOptionsBuilder optionsBuilder, string accountEndpoint, Azure.Core.TokenCredential tokenCredential, string databaseName, Action<Microsoft.EntityFrameworkCore.Infrastructure.CosmosDbContextOptionsBuilder>? cosmosOptionsAction = default);

Parameters

optionsBuilder
DbContextOptionsBuilder

The builder being used to configure the context.

accountEndpoint
String

The account end-point to connect to.

tokenCredential
TokenCredential

The Azure authentication token.

databaseName
String

The database name.

cosmosOptionsAction
Action<CosmosDbContextOptionsBuilder>

An optional action to allow additional Cosmos-specific configuration.

Returns

The options builder so that further configuration can be chained.

Remarks

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

Applies to

Entity Framework Core 9.0 and other versions
Product Versions
Entity Framework Core 7.0, 8.0, 9.0

UseCosmos(DbContextOptionsBuilder, String, String, String, Action<CosmosDbContextOptionsBuilder>)

Source:
CosmosDbContextOptionsExtensions.cs
Source:
CosmosDbContextOptionsExtensions.cs
Source:
CosmosDbContextOptionsExtensions.cs
Source:
CosmosDbContextOptionsExtensions.cs
Source:
CosmosDbContextOptionsExtensions.cs
Source:
CosmosDbContextOptionsExtensions.cs
Source:
CosmosDbContextOptionsExtensions.cs

Configures the context to connect to an Azure Cosmos database.

C#
public static Microsoft.EntityFrameworkCore.DbContextOptionsBuilder UseCosmos (this Microsoft.EntityFrameworkCore.DbContextOptionsBuilder optionsBuilder, string accountEndpoint, string accountKey, string databaseName, Action<Microsoft.EntityFrameworkCore.Infrastructure.CosmosDbContextOptionsBuilder> cosmosOptionsAction = default);
C#
public static Microsoft.EntityFrameworkCore.DbContextOptionsBuilder UseCosmos (this Microsoft.EntityFrameworkCore.DbContextOptionsBuilder optionsBuilder, string accountEndpoint, string accountKey, string databaseName, Action<Microsoft.EntityFrameworkCore.Infrastructure.CosmosDbContextOptionsBuilder>? cosmosOptionsAction = default);

Parameters

optionsBuilder
DbContextOptionsBuilder

The builder being used to configure the context.

accountEndpoint
String

The account end-point to connect to.

accountKey
String

The account key.

databaseName
String

The database name.

cosmosOptionsAction
Action<CosmosDbContextOptionsBuilder>

An optional action to allow additional Cosmos-specific configuration.

Returns

The options builder so that further configuration can be chained.

Remarks

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

Applies to

Entity Framework Core 9.0 and other versions
Product Versions
Entity Framework Core 3.0, 3.1, 5.0, 6.0, 7.0, 8.0, 9.0

UseCosmos<TContext>(DbContextOptionsBuilder<TContext>, Action<CosmosDbContextOptionsBuilder>)

Source:
CosmosDbContextOptionsExtensions.cs

Configures the context to connect to an Azure Cosmos database. The connection details need to be specified in a separate call.

C#
public static Microsoft.EntityFrameworkCore.DbContextOptionsBuilder<TContext> UseCosmos<TContext> (this Microsoft.EntityFrameworkCore.DbContextOptionsBuilder<TContext> optionsBuilder, Action<Microsoft.EntityFrameworkCore.Infrastructure.CosmosDbContextOptionsBuilder> cosmosOptionsAction) where TContext : Microsoft.EntityFrameworkCore.DbContext;

Type Parameters

TContext

The type of context to be configured.

Parameters

optionsBuilder
DbContextOptionsBuilder<TContext>

The builder being used to configure the context.

cosmosOptionsAction
Action<CosmosDbContextOptionsBuilder>

An action to allow Cosmos-specific configuration.

Returns

The options builder so that further configuration can be chained.

Remarks

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

Applies to

Entity Framework Core 9.0
Product Versions
Entity Framework Core 9.0

UseCosmos<TContext>(DbContextOptionsBuilder<TContext>, String, String, Action<CosmosDbContextOptionsBuilder>)

Source:
CosmosDbContextOptionsExtensions.cs
Source:
CosmosDbContextOptionsExtensions.cs
Source:
CosmosDbContextOptionsExtensions.cs
Source:
CosmosDbContextOptionsExtensions.cs
Source:
CosmosDbContextOptionsExtensions.cs

Configures the context to connect to an Azure Cosmos database.

C#
public static Microsoft.EntityFrameworkCore.DbContextOptionsBuilder<TContext> UseCosmos<TContext> (this Microsoft.EntityFrameworkCore.DbContextOptionsBuilder<TContext> optionsBuilder, string connectionString, string databaseName, Action<Microsoft.EntityFrameworkCore.Infrastructure.CosmosDbContextOptionsBuilder> cosmosOptionsAction = default) where TContext : Microsoft.EntityFrameworkCore.DbContext;
C#
public static Microsoft.EntityFrameworkCore.DbContextOptionsBuilder<TContext> UseCosmos<TContext> (this Microsoft.EntityFrameworkCore.DbContextOptionsBuilder<TContext> optionsBuilder, string connectionString, string databaseName, Action<Microsoft.EntityFrameworkCore.Infrastructure.CosmosDbContextOptionsBuilder>? cosmosOptionsAction = default) where TContext : Microsoft.EntityFrameworkCore.DbContext;

Type Parameters

TContext

The type of context to be configured.

Parameters

optionsBuilder
DbContextOptionsBuilder<TContext>

The builder being used to configure the context.

connectionString
String

The connection string of the database to connect to.

databaseName
String

The database name.

cosmosOptionsAction
Action<CosmosDbContextOptionsBuilder>

An optional action to allow additional Cosmos-specific configuration.

Returns

The options builder so that further configuration can be chained.

Remarks

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

Applies to

Entity Framework Core 9.0 and other versions
Product Versions
Entity Framework Core 5.0, 6.0, 7.0, 8.0, 9.0

UseCosmos<TContext>(DbContextOptionsBuilder<TContext>, String, TokenCredential, String, Action<CosmosDbContextOptionsBuilder>)

Source:
CosmosDbContextOptionsExtensions.cs
Source:
CosmosDbContextOptionsExtensions.cs
Source:
CosmosDbContextOptionsExtensions.cs

Configures the context to connect to an Azure Cosmos database.

C#
public static Microsoft.EntityFrameworkCore.DbContextOptionsBuilder<TContext> UseCosmos<TContext> (this Microsoft.EntityFrameworkCore.DbContextOptionsBuilder<TContext> optionsBuilder, string accountEndpoint, Azure.Core.TokenCredential tokenCredential, string databaseName, Action<Microsoft.EntityFrameworkCore.Infrastructure.CosmosDbContextOptionsBuilder>? cosmosOptionsAction = default) where TContext : Microsoft.EntityFrameworkCore.DbContext;

Type Parameters

TContext

The type of context to be configured.

Parameters

optionsBuilder
DbContextOptionsBuilder<TContext>

The builder being used to configure the context.

accountEndpoint
String

The account end-point to connect to.

tokenCredential
TokenCredential

The Azure authentication token.

databaseName
String

The database name.

cosmosOptionsAction
Action<CosmosDbContextOptionsBuilder>

An optional action to allow additional Cosmos-specific configuration.

Returns

The options builder so that further configuration can be chained.

Remarks

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

Applies to

Entity Framework Core 9.0 and other versions
Product Versions
Entity Framework Core 7.0, 8.0, 9.0

UseCosmos<TContext>(DbContextOptionsBuilder<TContext>, String, String, String, Action<CosmosDbContextOptionsBuilder>)

Source:
CosmosDbContextOptionsExtensions.cs
Source:
CosmosDbContextOptionsExtensions.cs
Source:
CosmosDbContextOptionsExtensions.cs
Source:
CosmosDbContextOptionsExtensions.cs
Source:
CosmosDbContextOptionsExtensions.cs
Source:
CosmosDbContextOptionsExtensions.cs
Source:
CosmosDbContextOptionsExtensions.cs

Configures the context to connect to an Azure Cosmos database.

C#
public static Microsoft.EntityFrameworkCore.DbContextOptionsBuilder<TContext> UseCosmos<TContext> (this Microsoft.EntityFrameworkCore.DbContextOptionsBuilder<TContext> optionsBuilder, string accountEndpoint, string accountKey, string databaseName, Action<Microsoft.EntityFrameworkCore.Infrastructure.CosmosDbContextOptionsBuilder> cosmosOptionsAction = default) where TContext : Microsoft.EntityFrameworkCore.DbContext;
C#
public static Microsoft.EntityFrameworkCore.DbContextOptionsBuilder<TContext> UseCosmos<TContext> (this Microsoft.EntityFrameworkCore.DbContextOptionsBuilder<TContext> optionsBuilder, string accountEndpoint, string accountKey, string databaseName, Action<Microsoft.EntityFrameworkCore.Infrastructure.CosmosDbContextOptionsBuilder>? cosmosOptionsAction = default) where TContext : Microsoft.EntityFrameworkCore.DbContext;

Type Parameters

TContext

The type of context to be configured.

Parameters

optionsBuilder
DbContextOptionsBuilder<TContext>

The builder being used to configure the context.

accountEndpoint
String

The account end-point to connect to.

accountKey
String

The account key.

databaseName
String

The database name.

cosmosOptionsAction
Action<CosmosDbContextOptionsBuilder>

An optional action to allow additional Cosmos-specific configuration.

Returns

The options builder so that further configuration can be chained.

Remarks

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

Applies to

Entity Framework Core 9.0 and other versions
Product Versions
Entity Framework Core 3.0, 3.1, 5.0, 6.0, 7.0, 8.0, 9.0