.Net Core Identity Stores using Marten
The users and roles stores are tested by using the offical Microsoft.AspNetCore.Identity.Specification.Tests packages. Have a look at the Marten.AspNetCore.Identity.Tests project. To run the tests you should have docker installed. A PostgreSQL image will be automatically downloaded and used during the test.
This repository has a small example project which setup the Microsoft Identity to use this package.
-
Add this package to your project.
-
While adding the default Marten support, you should configure the MartenIdentityUser and MartenIdentityRole entities:
builder.Services.AddMarten(options =>
{
options.Connection(builder.Configuration.GetConnectionString("Marten"));
// Configure the MartenIdentityUser and MartenIdentityRole mappings
options.ConfigureMartenIdentityMapping();
if (builder.Environment.IsDevelopment())
{
options.AutoCreateSchemaObjects = AutoCreate.All;
}
});
- Add the MartenIdentityStores
builder.Services.AddMartenIdentityStores();
- Configure the default identity to be MartenIdentityUser.
builder.Services.AddDefaultIdentity<MartenIdentityUser>();