NHibernate.AspNetCore.Identity 9.0.7
NHibernate.AspNetCore.Identity
ASP.NET Core Identity Provider implemented with NHibernate

Nuget package:
About Version
- 9.0.x is compatible with .Net 9.0.x;
- 8.0.x is compatible with .Net 8.0.x;
- 7.0.x is compatible with .Net 7.0.x;
- 6.0.x is compatible with .Net 6.0.x;
- 5.0.x is compatible with .Net 5.0.x;
- 3.1.x is compatible with .Net Core 3.1.x;
- 3.0.x is compatible with .Net Core 3.0.x;
Usage
1. Create a Asp.Net Core Mvc Project with identity support
dotnet new mvc --auth Individual
2. Add reference to NHibernate.AspNetCore.Identity and NHibernate.NetCore
dotnet add package NHibernate.AspNetCore.Identity
dotnet add package NHibernate.NetCore
NHibernatewill be installed automatically.
3. Setup database
Use the sql scripts in
databasefolder to create aspnet identity related tables, only support postgresql, mssql and mysql now;If you want other database support, please let me know, any issue, pull request is welcome!
Config NHibernate to use your database;
4. Change Startup.cs to use database and nhibernate
public class Startup {
public void ConfigureServices(
IServiceCollection services
) {
// Remove EFCore stores.
// services.AddDbContext<ApplicationDbContext>(
// options =>
// options.UseSqlite(Configuration.GetConnectionString("DefaultConnection")));
// services.AddDefaultIdentity<IdentityUser>()
// .AddEntityFrameworkStores<ApplicationDbContext>();
// Add Hibernate stores
var cfg = new Configuration();
var file = Path.Combine(
AppDomain.CurrentDomain.BaseDirectory,
"hibernate.config"
);
cfg.Configure(file);
// Add identity mapping based on dialect config (dialet must contains
// PostgreSQL, MySQL, MsSql or Sqlite)
cfg.AddIdentityMappings();
// using default xml mapping.
cfg.AddAssembly(typeof(Startup).Assembly);
// using `NHibernate.Mapping.ByCode`, please comment the line above,
// and uncomment line flowing lines;
// var modelMapper = new NHibernate.Mapping.ByCode.ModelMapper();
// modelMapper.AddMapping<WebTest.Entities.AppRoleMapping>();
// modelMapper.AddMapping<WebTest.Entities.AppUserMapping>();
// modelMapper.AddMapping<WebTest.Entities.TodoItemMapping>();
// var mappings = modelMapper.CompileMappingForAllExplicitlyAddedEntities();
// cfg.AddMapping(mappings);
services.AddHibernate(cfg);
services.AddDefaultIdentity<WebTest.Entities.ApplicationUser>()
.AddRoles<WebTest.Entities.ApplicationRole>()
.AddHibernateStores();
}
}
Note: When using with SqlServer, you need add
System.Data.SqlClientpackage to your project.
For more detailed samples, please look at the WebTest project.
Credits
Special thanks to the following individuals, organisations and projects whose work is so important to the success of NHibernate (in no particular order):
No packages depend on NHibernate.AspNetCore.Identity.
Update to .NET 9.0.10;Update NHibernate to 5.6.0;Update other nuget packages;
.NET 9.0
- Microsoft.Extensions.Identity.Core (>= 9.0.10)
- Microsoft.Extensions.Identity.Stores (>= 9.0.10)
- NHibernate (>= 5.6.0)
| Version | Downloads | Last updated |
|---|---|---|
| 9.0.7 | 4 | 10/21/2025 |
| 9.0.5 | 8 | 08/19/2025 |
| 9.0.4 | 13 | 07/20/2025 |
| 9.0.3 | 19 | 05/29/2025 |
| 9.0.1 | 32 | 02/20/2025 |
| 9.0.0 | 34 | 12/01/2024 |
| 8.0.10 | 33 | 08/19/2024 |
| 8.0.9 | 42 | 07/15/2024 |
| 8.0.8 | 38 | 07/09/2024 |
| 8.0.7 | 42 | 06/12/2024 |
| 8.0.6 | 40 | 05/19/2024 |
| 8.0.5 | 43 | 04/05/2024 |
| 8.0.4 | 50 | 03/21/2024 |
| 8.0.3 | 46 | 03/02/2024 |
| 8.0.2 | 38 | 03/02/2024 |
| 8.0.1 | 42 | 01/01/2024 |
| 8.0.0 | 56 | 11/23/2023 |
| 7.0.12 | 44 | 10/03/2023 |
| 7.0.11 | 46 | 09/02/2023 |
| 7.0.10 | 44 | 08/25/2023 |
| 7.0.9 | 45 | 08/26/2023 |
| 7.0.8 | 59 | 08/04/2023 |
| 7.0.7 | 55 | 08/10/2023 |
| 7.0.5 | 50 | 07/09/2023 |
| 7.0.4 | 44 | 07/20/2023 |
| 7.0.3 | 45 | 08/09/2023 |
| 7.0.2 | 42 | 08/06/2023 |
| 7.0.1 | 53 | 08/02/2023 |
| 7.0.0 | 49 | 08/15/2023 |
| 6.0.12 | 50 | 11/27/2022 |
| 6.0.11 | 47 | 08/02/2023 |
| 6.0.10 | 43 | 08/07/2023 |
| 6.0.9 | 45 | 08/19/2023 |
| 6.0.8 | 44 | 07/22/2022 |
| 6.0.7 | 56 | 07/15/2023 |
| 6.0.6 | 56 | 08/20/2023 |
| 6.0.5 | 57 | 08/09/2023 |
| 6.0.4 | 50 | 06/08/2023 |
| 6.0.3 | 45 | 08/11/2023 |
| 6.0.2 | 48 | 07/05/2023 |
| 6.0.1 | 54 | 07/14/2023 |
| 6.0.0 | 48 | 06/14/2023 |
| 5.0.15 | 46 | 06/19/2023 |
| 5.0.14 | 50 | 08/09/2023 |
| 5.0.13 | 44 | 08/25/2023 |
| 5.0.12 | 53 | 06/25/2023 |
| 5.0.11 | 54 | 02/10/2023 |
| 5.0.10 | 53 | 08/24/2023 |
| 5.0.9 | 48 | 08/10/2023 |
| 5.0.8 | 53 | 04/21/2023 |
| 5.0.7 | 45 | 08/18/2023 |
| 5.0.6 | 53 | 06/02/2023 |
| 5.0.5 | 48 | 07/05/2023 |
| 5.0.4 | 45 | 06/16/2023 |
| 5.0.3 | 58 | 06/04/2023 |
| 5.0.2 | 49 | 02/02/2023 |
| 5.0.1 | 45 | 07/29/2023 |
| 5.0.0 | 54 | 06/07/2023 |
| 5.0.0-rc.2 | 42 | 08/05/2023 |
| 5.0.0-rc.1 | 47 | 09/24/2023 |
| 3.1.9 | 52 | 04/27/2023 |
| 3.1.8 | 46 | 07/12/2023 |
| 3.1.7 | 55 | 04/25/2023 |
| 3.1.6 | 57 | 07/19/2023 |
| 3.1.5 | 49 | 07/28/2023 |
| 3.1.4 | 54 | 07/09/2023 |
| 3.1.3 | 50 | 04/27/2023 |
| 3.1.2 | 46 | 06/11/2023 |
| 3.1.1 | 45 | 06/07/2023 |
| 3.1.0 | 57 | 08/07/2023 |
| 3.0.2 | 50 | 02/02/2023 |
| 3.0.1 | 51 | 04/25/2023 |
| 3.0.0 | 50 | 08/10/2023 |
| 1.6.0 | 48 | 06/05/2023 |
| 1.5.0 | 46 | 08/16/2023 |
| 1.4.0 | 47 | 08/09/2023 |
| 1.3.0 | 62 | 08/09/2023 |
| 1.2.0 | 51 | 05/05/2023 |
| 1.1.0 | 53 | 08/12/2023 |
| 1.0.1 | 48 | 05/13/2023 |
| 1.0.0 | 56 | 05/16/2023 |