This commit is contained in:
alexandre-spieser
2017-11-19 18:35:45 +00:00
+3 -2
View File
@@ -41,7 +41,7 @@ public class ApplicationRole : MongoIdentityRole<Guid>
} }
} }
``` ```
The `Id` field is automatically set at instantiation, this also applies to users inheriting from `MongoIdentityUser<int>`, where a random integer is assigned to the `Id`. It is however not advised to rely on such random mechanism to set the primary key of your document. Using documents inheriting from `MongoIdentityRole` and `MongoIdentityUser` is recommended. The `Id` field is automatically set at instantiation, this also applies to users inheriting from `MongoIdentityUser<int>`, where a random integer is assigned to the `Id`. It is however not advised to rely on such random mechanism to set the primary key of your document. Using documents inheriting from `MongoIdentityRole` and `MongoIdentityUser`, which both use the `Guid` type for primary keys, is recommended.
To add the stores, you can use the `IdentityBuilder` extension like so: To add the stores, you can use the `IdentityBuilder` extension like so:
@@ -55,7 +55,8 @@ services.AddIdentity<ApplicationUser, ApplicationRole>()
.AddDefaultTokenProviders(); .AddDefaultTokenProviders();
``` ```
It is also possible to share a common `IMongoDbContext` across your services:
It is also possible to share a common `IMongoDbContext` across your services (requires https://www.nuget.org/packages/MongoDbGenericRepository/):
```csharp ```csharp
var mongoDbContext = new MongoDbContext("mongodb://localhost:27017", "MongoDbTests"); var mongoDbContext = new MongoDbContext("mongodb://localhost:27017", "MongoDbTests");