Using:
- Add MongoDb connеction info in config.json
{
"MongoIdentity": {
"ConnectionString": "mongodb://localhost",
"IdentityDatabase": "MongoIdentity",
"UserTableName": "Users", **Optional
"RoleTableName": "Roles" **Optional
}
}- Create models: AccountViewModels.cs
public class ApplicationUser : User
{
public string FirstName { get; set; }
public string LastName { get; set; }
public DateTime BirthDay { get; set; }
}
public class ApplicationRole : Role
{
public string Desription { get; set; }
}- Add Identity services to the services container Startup.cs
public void ConfigureServices(IServiceCollection services)
{
// Add Identity services to the services container.
services.AddMongoIdentity<ApplicationUser, ApplicationRole>(Configuration);
// Configure Mongo Identity Options (optional)
services.Configure<MongoIdentityOptions>(o => o.IdentityDatabase = "MongoIdentity");
// Add MVC services to the services container.
services.AddMvc();
}