AWS.AdvancedDotnetDataProviderWrapper.NHibernate 2.2.0

Prefix Reserved
dotnet add package AWS.AdvancedDotnetDataProviderWrapper.NHibernate --version 2.2.0
                    
NuGet\Install-Package AWS.AdvancedDotnetDataProviderWrapper.NHibernate -Version 2.2.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="AWS.AdvancedDotnetDataProviderWrapper.NHibernate" Version="2.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AWS.AdvancedDotnetDataProviderWrapper.NHibernate" Version="2.2.0" />
                    
Directory.Packages.props
<PackageReference Include="AWS.AdvancedDotnetDataProviderWrapper.NHibernate" />
                    
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 AWS.AdvancedDotnetDataProviderWrapper.NHibernate --version 2.2.0
                    
#r "nuget: AWS.AdvancedDotnetDataProviderWrapper.NHibernate, 2.2.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.
#:package AWS.AdvancedDotnetDataProviderWrapper.NHibernate@2.2.0
                    
#: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=AWS.AdvancedDotnetDataProviderWrapper.NHibernate&version=2.2.0
                    
Install as a Cake Addin
#tool nuget:?package=AWS.AdvancedDotnetDataProviderWrapper.NHibernate&version=2.2.0
                    
Install as a Cake Tool

AWS Advanced .NET Data Provider Wrapper - NHibernate Integration

Overview

This project provides NHibernate integration for the AWS Advanced .NET Data Provider Wrapper, enabling NHibernate applications to take full advantage of AWS Aurora features such as automatic failover, enhanced failure monitoring, and cluster topology awareness.

Usage

Basic Configuration

Configure NHibernate to use the AWS Wrapper Driver with your underlying database driver:

using AwsWrapperDataProvider.NHibernate;
using NHibernate.Cfg;
using NHibernate.Driver.MySqlConnector;

var connectionString = "Server=your-aurora-cluster.cluster-xyz.us-east-1.rds.amazonaws.com;" +
                       "Database=mydb;" +
                       "User Id=myuser;" +
                       "Password=mypassword;" +
                       "Plugins=failover,initialConnection;";

var cfg = new Configuration()
    .AddAssembly(Assembly.GetExecutingAssembly())
    .AddProperties(new Dictionary<string, string>
    {
        { "connection.connection_string", connectionString },
        { "dialect", "NHibernate.Dialect.MySQLDialect" },
    });

// Configure to use AWS Wrapper Driver with MySqlConnector
cfg.DataBaseIntegration(c => c.UseAwsWrapperDriver<MySqlConnectorDriver>());

var sessionFactory = cfg.BuildSessionFactory();

Connection String Parameters

For detailed information about all available connection string parameters, plugins, and configuration options, see the main documentation

Exception Handling

Important: NHibernate wraps underlying exceptions in HibernateException. When handling failover scenarios, you must catch HibernateException and check the InnerException for AWS wrapper-specific exceptions like FailoverSuccessException or TransactionStateUnknownException.

try
{
    using var session = sessionFactory.OpenSession();
    using var transaction = session.BeginTransaction();
    
    // Your NHibernate operations
    session.Save(entity);
    await transaction.CommitAsync();
}
catch (HibernateException ex) when (ex.InnerException is FailoverSuccessException)
{
    // Failover completed successfully - the operation may need to be retried
    Console.WriteLine($"Failover completed successfully: {ex.InnerException.Message}");
}
catch (HibernateException ex) when (ex.InnerException is TransactionStateUnknownException)
{
    // Transaction state is unknown after failover
    Console.WriteLine($"Transaction state unknown: {ex.InnerException.Message}");
}
catch (HibernateException ex)
{
    // Other NHibernate exceptions
    Console.WriteLine($"NHibernate error: {ex.Message}");
}

Supported Database Drivers

The NHibernate integration supports wrapping the following underlying drivers:

  • MySqlConnector: UseAwsWrapperDriver<MySqlConnectorDriver>()
  • Npgsql (PostgreSQL): UseAwsWrapperDriver<NpgsqlDriver>()

Example

See the complete NHibernateExample project for a working demonstration that shows:

  • How to configure NHibernate with the AWS Wrapper Driver
  • Proper exception handling for failover scenarios
  • Continuous database operations with automatic failover handling

Documentation

For comprehensive information about the AWS Advanced .NET Data Provider Wrapper visit the main documentation directory.

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.  net9.0 was computed.  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
2.2.0 97 8/5/2026
2.1.0 107 7/16/2026
2.0.0 121 6/16/2026
1.2.0 114 6/3/2026
1.1.0 126 3/24/2026
1.0.1 178 11/7/2025