mirror of
https://gitee.com/dcren/openiddict-documentation.git
synced 2025-09-18 17:48:00 +08:00
Update the MongoDB integration docs to indicate how to register an IMongoDatabase instance as a service
This commit is contained in:
@@ -15,7 +15,21 @@ To configure OpenIddict to use MongoDB as the database for applications, authori
|
||||
// that accepts a connection string or an instance of MongoClientSettings.
|
||||
options.UseMongoDb()
|
||||
.UseDatabase(new MongoClient().GetDatabase("openiddict"));
|
||||
})
|
||||
});
|
||||
```
|
||||
|
||||
Alternatively, you can register the `IMongoDatabase` instance as a service:
|
||||
|
||||
```csharp
|
||||
services.AddOpenIddict()
|
||||
.AddCore(options =>
|
||||
{
|
||||
options.UseMongoDb();
|
||||
});
|
||||
|
||||
// Note: to use a remote server, call the MongoClient constructor overload
|
||||
// that accepts a connection string or an instance of MongoClientSettings.
|
||||
services.AddSingleton(new MongoClient().GetDatabase("shared-database-instance"));
|
||||
```
|
||||
|
||||
- **Create indexes to improve performance** (recommended): for that, you can use the following script to
|
||||
|
Reference in New Issue
Block a user