AspNetCoreIdentity.MongoDriver
0.9.0.6
dotnet add package AspNetCoreIdentity.MongoDriver --version 0.9.0.6
NuGet\Install-Package AspNetCoreIdentity.MongoDriver -Version 0.9.0.6
<PackageReference Include="AspNetCoreIdentity.MongoDriver" Version="0.9.0.6" />
<PackageVersion Include="AspNetCoreIdentity.MongoDriver" Version="0.9.0.6" />
<PackageReference Include="AspNetCoreIdentity.MongoDriver" />
paket add AspNetCoreIdentity.MongoDriver --version 0.9.0.6
#r "nuget: AspNetCoreIdentity.MongoDriver, 0.9.0.6"
#:package AspNetCoreIdentity.MongoDriver@0.9.0.6
#addin nuget:?package=AspNetCoreIdentity.MongoDriver&version=0.9.0.6
#tool nuget:?package=AspNetCoreIdentity.MongoDriver&version=0.9.0.6
AspNetCoreIdentity.MongoDriver
A provisioner for AspNetCore Identity using MongoDB as the backing store.
Features
This implements all of the interfaces required by the AspNetCore Identity system.
It also includes a UserStore
and RoleStore
implementation that can be used with the UserManager
and RoleManager
classes.
A typical connection string for local development would be mongodb://localhost:27017/Identity
.
This would create a database called Identity
and store the collections in there.
Usage
builder.services.AddIdentityMongoDbProvider<MongoUser<Guid>, MongoRole<Guid>, Guid>(identity =>
{
identity.User.RequireUniqueEmail = true;
}, mongo =>
{
mongo.ConnectionString = builder.Configuration.GetConnectionString("MongoDb")!;
mongo.DisableAutoMigrations = true;
});
IServiceProvider serviceProvider = builder.services.BuildServiceProvider();
IServiceScope scope = serviceProvider.CreateScope();
UserManager = scope.ServiceProvider.GetService<UserManager<MongoUser<Guid>>>()!;
RoleManager = scope.ServiceProvider.GetService<RoleManager<MongoRole<Guid>>>()!;
The MongoUser
and MongoRole
classes are provided by the library and are generic. This allows you to use any type for the key, not just a Guid
.
If you want to use a Guid
as the key, you need to insert the line BsonSerializer.RegisterSerializer(new GuidSerializer(GuidRepresentation.Standard));
somewhere above this.
UserManager
and RoleManager
are IDisposable
and should be disposed of when they are no longer needed.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Microsoft.AspNetCore.DataProtection (>= 9.0.6)
- Microsoft.AspNetCore.Identity (>= 2.3.1)
- Microsoft.Extensions.Identity.Core (>= 9.0.6)
- Microsoft.Extensions.Identity.Stores (>= 9.0.6)
- MongoDB.Bson (>= 3.4.0)
- MongoDB.Driver (>= 3.4.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.