Skip to content

Latest commit

 

History

History
36 lines (25 loc) · 1.61 KB

README.md

File metadata and controls

36 lines (25 loc) · 1.61 KB

NuGet

MartenAspNetIdentity

MartenAspNetIdentity is a Marten DocumentDb implementation of Microsoft.AspNetCore.Identity.

Example usage

// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
    services.AddLogging();

    string connectionString = "server=localhost;database=aspnetidentity;uid=aspnetidentity;pwd=aspnetidentity;";

    services.AddIdentity<ApplicationUser, IdentityRole>()
        .AddMartenStores<ApplicationUser, IdentityRole>(connectionString)
        .AddDefaultTokenProviders();

    // more service wireup...
}
  • ApplicationUser is your user class to store.
  • IdentityRole is the role to store.

This will create an IDocumentStore for you, create a database and using the connection string provided, and add it to your services. If you already have an IDocumentStore configured in your DI container, you can use the overload without the connection string, the MartenAspNetIdentity will use this for its managers:

services.AddIdentity<ApplicationUser, IdentityRole>()
        .AddMartenStores<ApplicationUser, IdentityRole>()
        .AddDefaultTokenProviders();

There is a full example in this repository under the Example project