NHibernate.AspNetCore.Identity 9.0.4

dotnet add package NHibernate.AspNetCore.Identity --version 9.0.4
                    
NuGet\Install-Package NHibernate.AspNetCore.Identity -Version 9.0.4
                    
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="NHibernate.AspNetCore.Identity" Version="9.0.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NHibernate.AspNetCore.Identity" Version="9.0.4" />
                    
Directory.Packages.props
<PackageReference Include="NHibernate.AspNetCore.Identity" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add NHibernate.AspNetCore.Identity --version 9.0.4
                    
#r "nuget: NHibernate.AspNetCore.Identity, 9.0.4"
                    
#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.
#:package NHibernate.AspNetCore.Identity@9.0.4
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=NHibernate.AspNetCore.Identity&version=9.0.4
                    
Install as a Cake Addin
#tool nuget:?package=NHibernate.AspNetCore.Identity&version=9.0.4
                    
Install as a Cake Tool

NHibernate.AspNetCore.Identity

ASP.NET Core Identity Provider implemented with NHibernate

ASP.NET Core Identity with nhibernate

Database diagram

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

NHibernate will be installed automatically.

3. Setup database

  • Use the sql scripts in database folder 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.SqlClient package 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):

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
9.0.4 25 a month ago
9.0.3 658 3 months ago
9.0.1 1,489 6 months ago
9.0.0 744 8 months ago
8.0.10 1,497 8/19/2024
8.0.9 711 7/15/2024
8.0.8 288 7/8/2024
8.0.7 592 6/6/2024
8.0.6 345 5/11/2024
8.0.5 352 4/1/2024
8.0.4 201 3/20/2024
8.0.3 646 2/17/2024
8.0.2 274 2/4/2024
8.0.1 502 12/27/2023
8.0.0 643 11/19/2023
7.0.12 680 9/28/2023
7.0.11 548 9/2/2023
7.0.10 1,747 8/19/2023
7.0.9 238 8/4/2023
7.0.8 371 7/8/2023
7.0.7 251 7/8/2023
7.0.5 942 4/21/2023
7.0.4 538 4/10/2023
7.0.3 338 4/3/2023
7.0.2 304 4/3/2023
7.0.1 1,642 12/20/2022
7.0.0 562 12/10/2022
6.0.12 2,328 10/25/2022
6.0.11 772 10/3/2022
6.0.10 1,974 8/11/2022
6.0.9 726 7/29/2022
6.0.8 1,396 6/24/2022
6.0.7 1,014 5/21/2022
6.0.6 733 5/10/2022
6.0.5 768 4/18/2022
6.0.4 881 3/9/2022
6.0.3 789 2/21/2022
6.0.2 781 2/14/2022
6.0.1 1,781 12/16/2021
6.0.0 1,703 11/21/2021
5.0.15 1,266 10/13/2021
5.0.14 670 9/28/2021
5.0.13 656 9/15/2021
5.0.12 759 8/16/2021
5.0.11 837 7/28/2021
5.0.10 744 7/6/2021
5.0.9 824 6/10/2021
5.0.8 649 5/21/2021
5.0.7 747 4/22/2021
5.0.6 665 4/13/2021
5.0.5 984 3/22/2021
5.0.4 781 2/24/2021
5.0.3 739 1/30/2021
5.0.2 997 12/15/2020
5.0.1 770 11/18/2020
5.0.0 702 11/11/2020
5.0.0-rc.2 343 11/2/2020
5.0.0-rc.1 346 9/15/2020
3.1.9 6,645 8/19/2020
3.1.8 14,842 6/15/2020
3.1.7 4,776 4/28/2020
3.1.6 7,144 4/4/2020
3.1.5 5,214 3/7/2020
3.1.4 815 2/9/2020
3.1.3 860 1/19/2020
3.1.2 1,202 12/6/2019
3.1.1 755 12/5/2019
3.1.0 764 12/4/2019
3.0.2 762 12/3/2019
3.0.1 865 10/26/2019
3.0.0 863 10/8/2019
1.6.0 1,454 8/14/2019
1.5.0 1,156 5/10/2019
1.4.0 1,040 4/22/2019
1.3.0 941 4/18/2019
1.2.0 4,444 10/23/2018
1.1.0 1,353 8/18/2018
1.0.1 1,278 8/8/2018
1.0.0 1,339 7/20/2018

Update to .NET 9.0.7;Update Identity.Core to 9.0.7;