MongoDB data store for AspNetCore.Identity 2.0
https://www.nuget.org/packages/FB.AspNetCore.Identity.MongoDB
You have to add the following lines to your Startup.cs in the ASP.NET Core Project.
public void ConfigureServices(IServiceCollection services)
{
services.AddIdentity<ApplicationUser, MongoIdentityRole>()
.AddDefaultTokenProviders();
services
.Configure<MongoDBOption>(Configuration.GetSection("MongoDBOption"))
.AddMongoDatabase()
.AddMongoDbContext<ApplicationUser, MongoIdentityRole>()
.AddMongoStore<ApplicationUser, MongoIdentityRole>();
}
Also make sure you use the right inheritance in the Models class ApplicationUser.
public class ApplicationUser : MongoIdentityUser
{
}
In appsettings.json you can configure the correct Path to your MongoDB instance.
{
"ConnectionStrings": {
"DefaultConnection": "Server=xxxx"
},
"MongoDBOption": {
"ConnectionString": "mongodb://192.168.103.115:27017",
"Database": "AspCoreIdentity",
"User": {
"CollectionName": "Users",
"ManageIndicies": true
},
"Role": {
"CollectionName": "Roles",
"ManageIndicies": true
}
},
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Warning"
}
}
}