If you're already running MongoDB and you reach for ASP.NET Core Identity, the
official story points you at Entity Framework Core. That's a fine answer if you
have a relational database. If you don't, you end up bolting a second data
access stack onto an app that has exactly one store. You don't need it.
AspNetCoreIdentity.MongoDriver is a store provider that talks to Mongo through
the official MongoDB.Driver directly — no EF Core, no SQL, no second
persistence model. It implements the Identity store interfaces, ships a
UserStore and RoleStore, and wires up UserManager/RoleManager the way
you already expect.
The 15-line version
Register the provider in Program.cs:
builder.Services.AddIdentityMongoDbProvider<MongoUser<Guid>, MongoRole<Guid>, Guid>(identity =>
{
identity.User.RequireUniqueEmail = true;
}, mongo =>
{
mongo.ConnectionString = builder.Configuration.GetConnectionString("MongoDb")!;
});
A connection string like mongodb://
Discussion
Jump in and comment!
Get the ball rolling with your comment!