Table of Contents

Method UseMongoDB

Namespace
Microsoft.EntityFrameworkCore
Assembly
MongoDB.EntityFrameworkCore.dll

UseMongoDB<TContext>(DbContextOptionsBuilder<TContext>, string, string, Action<MongoDbContextOptionsBuilder>?)

Configures the DbContext subclass to connect to a MongoDB database.

public static DbContextOptionsBuilder<TContext> UseMongoDB<TContext>(this DbContextOptionsBuilder<TContext> optionsBuilder, string connectionString, string databaseName, Action<MongoDbContextOptionsBuilder>? optionsAction = null) where TContext : DbContext

Parameters

optionsBuilder DbContextOptionsBuilder<TContext>

The builder being used to configure the context.

connectionString string

The connection string used to identify the MongoDB server to use.

databaseName string

The name of the database to use on the MongoDB server.

optionsAction Action<MongoDbContextOptionsBuilder>

An optional action to allow additional MongoDB-specific configuration.

Returns

DbContextOptionsBuilder<TContext>

The options builder so that further configuration can be chained.

Type Parameters

TContext

The type of context to be configured.

UseMongoDB(DbContextOptionsBuilder, string, string, Action<MongoDbContextOptionsBuilder>?)

Configures the context to connect to a MongoDB database using the DbContextOptionsBuilder.

public static DbContextOptionsBuilder UseMongoDB(this DbContextOptionsBuilder optionsBuilder, string connectionString, string databaseName, Action<MongoDbContextOptionsBuilder>? optionsAction = null)

Parameters

optionsBuilder DbContextOptionsBuilder

The builder being used to configure the context.

connectionString string

The connection string used to identify the MongoDB server to use.

databaseName string

The name of the database to use on the MongoDB server.

optionsAction Action<MongoDbContextOptionsBuilder>

An optional action to allow additional MongoDB-specific configuration.

Returns

DbContextOptionsBuilder

The options builder so that further configuration can be chained.

UseMongoDB<TContext>(DbContextOptionsBuilder<TContext>, IMongoClient, string, Action<MongoDbContextOptionsBuilder>?)

Configures the DbContext subclass to connect to a MongoDB database.

public static DbContextOptionsBuilder<TContext> UseMongoDB<TContext>(this DbContextOptionsBuilder<TContext> optionsBuilder, IMongoClient mongoClient, string databaseName, Action<MongoDbContextOptionsBuilder>? optionsAction = null) where TContext : DbContext

Parameters

optionsBuilder DbContextOptionsBuilder<TContext>

The builder being used to configure the context.

mongoClient IMongoClient

The connections string used to identify the MongoDB server to use.

databaseName string

The name of the MongoDB database to use on the server.

optionsAction Action<MongoDbContextOptionsBuilder>

An optional action to allow additional MongoDB-specific configuration.

Returns

DbContextOptionsBuilder<TContext>

The options builder so that further configuration can be chained.

Type Parameters

TContext

The type of context to be configured.

UseMongoDB(DbContextOptionsBuilder, IMongoClient, string, Action<MongoDbContextOptionsBuilder>?)

Configures the context to connect to a MongoDB database using the DbContextOptionsBuilder.

public static DbContextOptionsBuilder UseMongoDB(this DbContextOptionsBuilder optionsBuilder, IMongoClient mongoClient, string databaseName, Action<MongoDbContextOptionsBuilder>? optionsAction = null)

Parameters

optionsBuilder DbContextOptionsBuilder

The builder being used to configure the context.

mongoClient IMongoClient

The connections string used to identify the MongoDB server to use.

databaseName string

The name of the MongoDB database to use on the server.

optionsAction Action<MongoDbContextOptionsBuilder>

An optional action to allow additional MongoDB-specific configuration.

Returns

DbContextOptionsBuilder

The options builder so that further configuration can be chained.