Identity Core package for using RavenDB with ASP.NET Core Identity.
This package is used as a replacement for the EntityFrameworkCore package and makes it possible to use RavenDB as your database for storing users and roles, while being fully compatible with the Identity framework. This package supports .NET Standard 2.*
, .NET CORE 2.*
, and .NET Core 3.*
Install the RavenDB.AspNetCore.IdentityCore library through NuGet.
Install-Package RavenDB.AspNetCore.IdentityCore
Or
Install-Package RavenDB.AspNetCore.IdentityCore -Pre
Add this to your Startup.cs:
public IServiceProvider ConfigureServices(IServiceCollection services)
{
...
var store = new DocumentStore
{
Urls = new[]
{
"http://localhost:8080"
},
Database = "RavenDB-Identity"
}.Initialize();
services
.AddIdentity<RavenIdentityUser, RavenIdentityRole>()
.AddRavenStores(delegate (
IServiceProvider provider)
{
return store.OpenAsyncSession();
})
.AddDefaultUI(UIFramework.Bootstrap4)
.AddDefaultTokenProviders();
...
}
Optional if you want to implement your own user/role model:
Note: Don't forget to change IdentityUser to ApplicationUser in the Startup.cs.
public class ApplicationUser
: RavenIdentityUser
{
public ApplicationUser(
string userName,
string email)
: base(userName, email)
{
}
/// <summary>
/// User's first name
/// </summary>
public string FirstName { get; set; }
/// <summary>
/// User's last name
/// </summary>
public string LastName { get; set; }
}
}
If you have any problems with or questions about this image, please contact us through a GitHub issue.