CosmosDbContextOptionsExtensions.UseCosmos 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
重载
UseCosmos(DbContextOptionsBuilder, String, String, Action<CosmosDbContextOptionsBuilder>) |
配置上下文以连接到 Azure Cosmos 数据库。 |
UseCosmos(DbContextOptionsBuilder, String, TokenCredential, String, Action<CosmosDbContextOptionsBuilder>) |
配置上下文以连接到 Azure Cosmos 数据库。 |
UseCosmos(DbContextOptionsBuilder, String, String, String, Action<CosmosDbContextOptionsBuilder>) |
配置上下文以连接到 Azure Cosmos 数据库。 |
UseCosmos<TContext>(DbContextOptionsBuilder<TContext>, String, String, Action<CosmosDbContextOptionsBuilder>) |
配置上下文以连接到 Azure Cosmos 数据库。 |
UseCosmos<TContext>(DbContextOptionsBuilder<TContext>, String, TokenCredential, String, Action<CosmosDbContextOptionsBuilder>) |
配置上下文以连接到 Azure Cosmos 数据库。 |
UseCosmos<TContext>(DbContextOptionsBuilder<TContext>, String, String, String, Action<CosmosDbContextOptionsBuilder>) |
配置上下文以连接到 Azure Cosmos 数据库。 |
UseCosmos(DbContextOptionsBuilder, String, String, Action<CosmosDbContextOptionsBuilder>)
配置上下文以连接到 Azure Cosmos 数据库。
public static Microsoft.EntityFrameworkCore.DbContextOptionsBuilder UseCosmos (this Microsoft.EntityFrameworkCore.DbContextOptionsBuilder optionsBuilder, string connectionString, string databaseName, Action<Microsoft.EntityFrameworkCore.Infrastructure.CosmosDbContextOptionsBuilder> cosmosOptionsAction = default);
public static Microsoft.EntityFrameworkCore.DbContextOptionsBuilder UseCosmos (this Microsoft.EntityFrameworkCore.DbContextOptionsBuilder optionsBuilder, string connectionString, string databaseName, Action<Microsoft.EntityFrameworkCore.Infrastructure.CosmosDbContextOptionsBuilder>? cosmosOptionsAction = default);
static member UseCosmos : Microsoft.EntityFrameworkCore.DbContextOptionsBuilder * string * string * Action<Microsoft.EntityFrameworkCore.Infrastructure.CosmosDbContextOptionsBuilder> -> Microsoft.EntityFrameworkCore.DbContextOptionsBuilder
<Extension()>
Public Function UseCosmos (optionsBuilder As DbContextOptionsBuilder, connectionString As String, databaseName As String, Optional cosmosOptionsAction As Action(Of CosmosDbContextOptionsBuilder) = Nothing) As DbContextOptionsBuilder
参数
- optionsBuilder
- DbContextOptionsBuilder
用于配置上下文的生成器。
- connectionString
- String
要连接到的数据库的连接字符串。
- databaseName
- String
数据库名称。
- cosmosOptionsAction
- Action<CosmosDbContextOptionsBuilder>
一个可选操作,用于允许其他特定于 Cosmos 的配置。
返回
选项生成器,以便可以链接进一步的配置。
注解
有关详细信息和示例,请参阅 使用 DbContextOptions 和 使用 EF Core 访问 Azure Cosmos DB 。
适用于
UseCosmos(DbContextOptionsBuilder, String, TokenCredential, String, Action<CosmosDbContextOptionsBuilder>)
配置上下文以连接到 Azure Cosmos 数据库。
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);
static member UseCosmos : Microsoft.EntityFrameworkCore.DbContextOptionsBuilder * string * Azure.Core.TokenCredential * string * Action<Microsoft.EntityFrameworkCore.Infrastructure.CosmosDbContextOptionsBuilder> -> Microsoft.EntityFrameworkCore.DbContextOptionsBuilder
<Extension()>
Public Function UseCosmos (optionsBuilder As DbContextOptionsBuilder, accountEndpoint As String, tokenCredential As TokenCredential, databaseName As String, Optional cosmosOptionsAction As Action(Of CosmosDbContextOptionsBuilder) = Nothing) As DbContextOptionsBuilder
参数
- optionsBuilder
- DbContextOptionsBuilder
用于配置上下文的生成器。
- accountEndpoint
- String
要连接到的帐户终结点。
- tokenCredential
- TokenCredential
Azure 身份验证令牌。
- databaseName
- String
数据库名称。
- cosmosOptionsAction
- Action<CosmosDbContextOptionsBuilder>
一个可选操作,用于允许其他特定于 Cosmos 的配置。
返回
选项生成器,以便可以链接进一步的配置。
注解
有关详细信息和示例,请参阅 使用 DbContextOptions 和 使用 EF Core 访问 Azure Cosmos DB 。
适用于
UseCosmos(DbContextOptionsBuilder, String, String, String, Action<CosmosDbContextOptionsBuilder>)
配置上下文以连接到 Azure Cosmos 数据库。
public static Microsoft.EntityFrameworkCore.DbContextOptionsBuilder UseCosmos (this Microsoft.EntityFrameworkCore.DbContextOptionsBuilder optionsBuilder, string accountEndpoint, string accountKey, string databaseName, Action<Microsoft.EntityFrameworkCore.Infrastructure.CosmosDbContextOptionsBuilder> cosmosOptionsAction = default);
public static Microsoft.EntityFrameworkCore.DbContextOptionsBuilder UseCosmos (this Microsoft.EntityFrameworkCore.DbContextOptionsBuilder optionsBuilder, string accountEndpoint, string accountKey, string databaseName, Action<Microsoft.EntityFrameworkCore.Infrastructure.CosmosDbContextOptionsBuilder>? cosmosOptionsAction = default);
static member UseCosmos : Microsoft.EntityFrameworkCore.DbContextOptionsBuilder * string * string * string * Action<Microsoft.EntityFrameworkCore.Infrastructure.CosmosDbContextOptionsBuilder> -> Microsoft.EntityFrameworkCore.DbContextOptionsBuilder
<Extension()>
Public Function UseCosmos (optionsBuilder As DbContextOptionsBuilder, accountEndpoint As String, accountKey As String, databaseName As String, Optional cosmosOptionsAction As Action(Of CosmosDbContextOptionsBuilder) = Nothing) As DbContextOptionsBuilder
参数
- optionsBuilder
- DbContextOptionsBuilder
用于配置上下文的生成器。
- accountEndpoint
- String
要连接到的帐户终结点。
- accountKey
- String
帐户密钥。
- databaseName
- String
数据库名称。
- cosmosOptionsAction
- Action<CosmosDbContextOptionsBuilder>
一个可选操作,用于允许其他特定于 Cosmos 的配置。
返回
选项生成器,以便可以链接进一步的配置。
注解
有关详细信息和示例,请参阅 使用 DbContextOptions 和 使用 EF Core 访问 Azure Cosmos DB 。
适用于
UseCosmos<TContext>(DbContextOptionsBuilder<TContext>, String, String, Action<CosmosDbContextOptionsBuilder>)
配置上下文以连接到 Azure Cosmos 数据库。
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;
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;
static member UseCosmos : Microsoft.EntityFrameworkCore.DbContextOptionsBuilder<'Context (requires 'Context :> Microsoft.EntityFrameworkCore.DbContext)> * string * string * Action<Microsoft.EntityFrameworkCore.Infrastructure.CosmosDbContextOptionsBuilder> -> Microsoft.EntityFrameworkCore.DbContextOptionsBuilder<'Context (requires 'Context :> Microsoft.EntityFrameworkCore.DbContext)> (requires 'Context :> Microsoft.EntityFrameworkCore.DbContext)
<Extension()>
Public Function UseCosmos(Of TContext As DbContext) (optionsBuilder As DbContextOptionsBuilder(Of TContext), connectionString As String, databaseName As String, Optional cosmosOptionsAction As Action(Of CosmosDbContextOptionsBuilder) = Nothing) As DbContextOptionsBuilder(Of TContext)
类型参数
- TContext
要配置的上下文类型。
参数
- optionsBuilder
- DbContextOptionsBuilder<TContext>
用于配置上下文的生成器。
- connectionString
- String
要连接到的数据库的连接字符串。
- databaseName
- String
数据库名称。
- cosmosOptionsAction
- Action<CosmosDbContextOptionsBuilder>
一个可选操作,用于允许其他特定于 Cosmos 的配置。
返回
选项生成器,以便可以链接进一步的配置。
注解
有关详细信息和示例,请参阅 使用 DbContextOptions 和 使用 EF Core 访问 Azure Cosmos DB 。
适用于
UseCosmos<TContext>(DbContextOptionsBuilder<TContext>, String, TokenCredential, String, Action<CosmosDbContextOptionsBuilder>)
配置上下文以连接到 Azure Cosmos 数据库。
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;
static member UseCosmos : Microsoft.EntityFrameworkCore.DbContextOptionsBuilder<'Context (requires 'Context :> Microsoft.EntityFrameworkCore.DbContext)> * string * Azure.Core.TokenCredential * string * Action<Microsoft.EntityFrameworkCore.Infrastructure.CosmosDbContextOptionsBuilder> -> Microsoft.EntityFrameworkCore.DbContextOptionsBuilder<'Context (requires 'Context :> Microsoft.EntityFrameworkCore.DbContext)> (requires 'Context :> Microsoft.EntityFrameworkCore.DbContext)
<Extension()>
Public Function UseCosmos(Of TContext As DbContext) (optionsBuilder As DbContextOptionsBuilder(Of TContext), accountEndpoint As String, tokenCredential As TokenCredential, databaseName As String, Optional cosmosOptionsAction As Action(Of CosmosDbContextOptionsBuilder) = Nothing) As DbContextOptionsBuilder(Of TContext)
类型参数
- TContext
要配置的上下文类型。
参数
- optionsBuilder
- DbContextOptionsBuilder<TContext>
用于配置上下文的生成器。
- accountEndpoint
- String
要连接到的帐户终结点。
- tokenCredential
- TokenCredential
Azure 身份验证令牌。
- databaseName
- String
数据库名称。
- cosmosOptionsAction
- Action<CosmosDbContextOptionsBuilder>
一个可选操作,用于允许其他特定于 Cosmos 的配置。
返回
选项生成器,以便可以链接进一步的配置。
注解
有关详细信息和示例,请参阅 使用 DbContextOptions 和 使用 EF Core 访问 Azure Cosmos DB 。
适用于
UseCosmos<TContext>(DbContextOptionsBuilder<TContext>, String, String, String, Action<CosmosDbContextOptionsBuilder>)
配置上下文以连接到 Azure Cosmos 数据库。
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;
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;
static member UseCosmos : Microsoft.EntityFrameworkCore.DbContextOptionsBuilder<'Context (requires 'Context :> Microsoft.EntityFrameworkCore.DbContext)> * string * string * string * Action<Microsoft.EntityFrameworkCore.Infrastructure.CosmosDbContextOptionsBuilder> -> Microsoft.EntityFrameworkCore.DbContextOptionsBuilder<'Context (requires 'Context :> Microsoft.EntityFrameworkCore.DbContext)> (requires 'Context :> Microsoft.EntityFrameworkCore.DbContext)
<Extension()>
Public Function UseCosmos(Of TContext As DbContext) (optionsBuilder As DbContextOptionsBuilder(Of TContext), accountEndpoint As String, accountKey As String, databaseName As String, Optional cosmosOptionsAction As Action(Of CosmosDbContextOptionsBuilder) = Nothing) As DbContextOptionsBuilder(Of TContext)
类型参数
- TContext
要配置的上下文类型。
参数
- optionsBuilder
- DbContextOptionsBuilder<TContext>
用于配置上下文的生成器。
- accountEndpoint
- String
要连接到的帐户终结点。
- accountKey
- String
帐户密钥。
- databaseName
- String
数据库名称。
- cosmosOptionsAction
- Action<CosmosDbContextOptionsBuilder>
一个可选操作,用于允许其他特定于 Cosmos 的配置。
返回
选项生成器,以便可以链接进一步的配置。
注解
有关详细信息和示例,请参阅 使用 DbContextOptions 和 使用 EF Core 访问 Azure Cosmos DB 。