Update README.md

This commit is contained in:
Alexandre SPIESER
2017-11-14 13:52:33 +00:00
committed by GitHub
parent 8beeaf463d
commit 23d52d0275
+10 -10
View File
@@ -55,16 +55,6 @@ services.AddIdentity<ApplicationUser, ApplicationRole>()
.AddDefaultTokenProviders(); .AddDefaultTokenProviders();
``` ```
It is also possible to share a common `IMongoDbContext` across your services:
```csharp
var mongoDbContext = new MongoDbContext("mongodb://localhost:27017", "MongoDbTests");
services.AddIdentity<ApplicationUser, ApplicationRole>()
.AddMongoDbStores<IMongoDbContext>(mongoDbContext)
.AddDefaultTokenProviders();
// Use the mongoDbContext for other things.
```
You can also use the more explicit type declaration: You can also use the more explicit type declaration:
```csharp ```csharp
@@ -75,6 +65,16 @@ services.AddIdentity<ApplicationUser, ApplicationRole>()
// Use the mongoDbContext for other things. // Use the mongoDbContext for other things.
``` ```
It is also possible to share a common `IMongoDbContext` across your services (requires https://www.nuget.org/packages/MongoDbGenericRepository/):
```csharp
var mongoDbContext = new MongoDbContext("mongodb://localhost:27017", "MongoDbTests");
services.AddIdentity<ApplicationUser, ApplicationRole>()
.AddMongoDbStores<IMongoDbContext>(mongoDbContext)
.AddDefaultTokenProviders();
// Use the mongoDbContext for other things.
```
Alternatively a full configuration can be done by populating a `MongoDbIdentityConfiguration` object, which can have an `IdentityOptionsAction` property set to an action you want to perform against the `IdentityOptions` (`Action<IdentityOptions>`). Alternatively a full configuration can be done by populating a `MongoDbIdentityConfiguration` object, which can have an `IdentityOptionsAction` property set to an action you want to perform against the `IdentityOptions` (`Action<IdentityOptions>`).
The `MongoDbSettings` object is used to set MongoDb Settings using the `ConnectionString` and the `DatabaseName` properties. The `MongoDbSettings` object is used to set MongoDb Settings using the `ConnectionString` and the `DatabaseName` properties.