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
optionsBuilderDbContextOptionsBuilder<TContext>The builder being used to configure the context.
connectionStringstringThe connection string used to identify the MongoDB server to use.
databaseNamestringThe name of the database to use on the MongoDB server.
optionsActionAction<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
TContextThe 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
optionsBuilderDbContextOptionsBuilderThe builder being used to configure the context.
connectionStringstringThe connection string used to identify the MongoDB server to use.
databaseNamestringThe name of the database to use on the MongoDB server.
optionsActionAction<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
optionsBuilderDbContextOptionsBuilder<TContext>The builder being used to configure the context.
mongoClientIMongoClientThe connections string used to identify the MongoDB server to use.
databaseNamestringThe name of the MongoDB database to use on the server.
optionsActionAction<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
TContextThe 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
optionsBuilderDbContextOptionsBuilderThe builder being used to configure the context.
mongoClientIMongoClientThe connections string used to identify the MongoDB server to use.
databaseNamestringThe name of the MongoDB database to use on the server.
optionsActionAction<MongoDbContextOptionsBuilder>An optional action to allow additional MongoDB-specific configuration.
Returns
- DbContextOptionsBuilder
The options builder so that further configuration can be chained.