RavenDB.Identity 9.0.0

dotnet add package RavenDB.Identity --version 9.0.0
NuGet\Install-Package RavenDB.Identity -Version 9.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="RavenDB.Identity" Version="9.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add RavenDB.Identity --version 9.0.0
#r "nuget: RavenDB.Identity, 9.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install RavenDB.Identity as a Cake Addin
#addin nuget:?package=RavenDB.Identity&version=9.0.0

// Install RavenDB.Identity as a Cake Tool
#tool nuget:?package=RavenDB.Identity&version=9.0.0

<img src="https://github.com/JudahGabriel/RavenDB.Identity/blob/master/RavenDB.Identity/nuget-icon.png?raw=true" width="50px" height="50px" /> RavenDB.Identity

The simple and easy Identity provider for RavenDB and ASP.NET Core. Use Raven to store your users and roles.


Important: Upgrading from a previous version of RavenDB.Identity? See <a href="#updating-from-old-version">Updating From Old Version</a> for steps to migrate to the latest RavenDB.Identity.

  1. Add an AppUser class that derives from Raven.Identity.IdentityUser:
public class AppUser : Raven.Identity.IdentityUser
    /// <summary>
    /// A user's full name.
    /// </summary>
    public string FullName { get; set; }
  1. In appsettings.json, configure your connection to Raven:
"RavenSettings": {
    "Urls": [
    "DatabaseName": "Raven.Identity.Sample.RazorPages",
    "CertFilePath": "",
    "CertPassword": ""

3a. In Startup.cs, wire it all up. Note that this approach will use the email address as part of the User Id, such that changing their email will change their User Id as well:

public void ConfigureServices(IServiceCollection services)
    // Add RavenDB and identity.
        .AddRavenDbDocStore() // Create an IDocumentStore singleton from the RavenSettings.
        .AddRavenDbAsyncSession() // Create a RavenDB IAsyncDocumentSession for each request. You're responsible for calling .SaveChanges after each request.
        .AddIdentity<AppUser, IdentityRole>() // Adds an identity system to ASP.NET Core
        .AddRavenDbIdentityStores<AppUser, IdentityRole>(); // Use RavenDB as the store for identity users and roles. Specify your app user type here, and your role type. If you don't have a role type, use Raven.Identity.IdentityRole.

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    // Instruct ASP.NET Core to use authentication and authorization.
  1. In your controller actions, call .SaveChangesAsync() when you're done making changes. Typically this is done via a RavenController base class for MVC/WebAPI projects or via a page filter for Razor Pages projects.

Changing how user IDs are generated

Previous versions of RavenDB.Identity used email-based user IDs, e.g. "AppUser/johndoe@mail.com". Newer versions use Raven's default behavior, typically "AppUsers/1-A"`. To change how Raven controls IDs for your users, see Raven's Global Identifier Generation Conventions.

If you have old users in your database using the email-based ID convention, no problem, Raven.Identity will still work with the old users. If you want consistent IDs across all your users, you can migrate existing users to a new ID generation scheme using the ChangeUserIdType migration:

// Important: backup your database before running this migration.
var newIdType = UserIdType.ServerGenerated; // Or whatever ID type you prefer.
var migration = new Raven.Identity.Migrations.ChangeUserIdType(docStore, newIdType);
migration.Migrate<AppUser>(); // AppUser, or whatever you user type is.

Regardless of how IDs are generated, uniqueness is based on email address. You can't have 2 users in your database with the same email address.

Modifying RavenDB conventions

Need to modify RavenDB conventions? You can use the services.AddRavenDbDocStore(options) overload:

services.AddRavenDbDocStore(options =>
    // Maybe we want to change the identity parts separator.
    options.BeforeInitializeDocStore = docStore => docStore.Conventions.IdentityPartsSeparator = "-";

<a id="updating-from-old-version">Updating From Old Version of RavenDB.Identity</a>

Using RavenDB.Identity v5 or earlier and want to upgrade to the latest? You need to run the CompareExchangeUniqueness migration:

// Important: backup your database before running this migration.
var migration = new Raven.Identity.Migrations.CompareExchangeUniqueness(docStore);

This upgrade step is necessary because we updated RavenDB.Identity to use RavenDB's cluster-safe compare/exchange to enforce email-based uniqueness.

Previous versions of RavenDB.Identity had relied on IdentityUserByUserName IDs to enforce uniqueness, but this isn't guaranteed to work in a cluster. Doing this migration will create compare/exchange values in Raven for each user email address, and will remove the now-obsolete IdentityUserByUserNames collection.

Getting Started and Sample Project

Need help? Checkout the our samples to see how to use it:

Not using .NET Core?

See our sister project for a RavenDB Identity Provider for the full .NET Framework.

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (4)

Showing the top 4 NuGet packages that depend on RavenDB.Identity:

Package Downloads

Package Description


Package Description


Package Description


LeadSoft® RavenDB Identity Classes.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on RavenDB.Identity:

Repository Stars
Experimental project using AspNetCore Blazor
Version Downloads Last updated
9.0.0 6,160 1/13/2024
8.0.9 18,881 7/6/2023
8.0.8 3,310 4/20/2023
8.0.7 34,186 5/5/2021
8.0.6 1,354 4/1/2021
8.0.5 2,815 12/17/2020
8.0.4 2,435 9/22/2020
8.0.3 1,197 9/2/2020
8.0.2 1,843 7/28/2020
8.0.1 1,057 7/26/2020
8.0.0 1,067 7/25/2020
7.0.1 4,107 12/19/2019
7.0.0 1,169 12/13/2019 2,331 12/3/2019 1,118 11/28/2019
6.2.0 1,212 11/13/2019
6.1.0 3,555 7/8/2019
6.0.6 1,226 6/26/2019
6.0.5 1,167 6/10/2019
6.0.3 1,944 4/5/2019
6.0.2 4,808 4/1/2019
6.0.1 1,196 3/21/2019
5.0.1 1,190 3/11/2019
5.0.0 1,322 3/4/2019
4.4.1 3,923 10/8/2018
4.3.0 3,361 2/24/2018
4.2.0 1,557 2/23/2018
4.1.1 1,472 2/22/2018
4.0.1 1,601 2/11/2018
4.0.0 1,630 2/9/2018
3.0.0 1,732 9/28/2017
2.1.0 1,632 9/6/2017
2.0.4 1,640 9/5/2017
2.0.3 1,604 9/5/2017
2.0.2 1,611 8/29/2017
2.0.1 1,610 8/29/2017
2.0.0 2,066 8/29/2017
1.0.3 1,979 8/23/2017
1.0.1 5,733 8/23/2017
1.0.0 5,480 8/23/2017

Upgrades to .NET 8, Raven 6