I faced the below error fluentNhibernate in .net 6 project but the same code is working in framework 4.8.
Error: could not create the driver from nhibernate.driver.sqlclientdriver, nhibernate, version=5.3.0.0, culture=neutral, publickeytoken=aa95f207798dfdb4
My code in .net 6 is:
public class DatabaseContext
{
private static ISessionFactory session;
private static ISessionFactory CreateSession()
{
const string connectionString = "Data source=SQLEXPRESS;Database=**;Integrated Security=True";
if (session != null)
{
return session;
}
var sqlConfiguration = MsSqlConfiguration.MsSql2012.ConnectionString(connectionString);
return Fluently.Configure()
.Database(sqlConfiguration)
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<TokenMapping>())
.ExposeConfiguration(cfg => new SchemaExport(cfg).Execute(false, true, false))
.BuildSessionFactory();
}
public static NHibernate.ISession SessionOpen()
{
return CreateSession().OpenSession();
}
}