SQL Server 2019 Dialect

3,565 views
Skip to first unread message

Gregory

unread,
Apr 12, 2021, 3:09:08 AM4/12/21
to nhusers
NHibernate doesn't have the 2019 dialect for MS SQL server.

I tried using the 2012 dialect but it gives me an error saying "Could not create the driver from NHibernate.Driver.SqlClientDriver"

What should I do?

Frédéric Delaporte

unread,
Apr 12, 2021, 3:19:57 AM4/12/21
to nhusers
There is no need for a 2019 dialect. The 2012 one works just fine with any newer SQL Server version. Newer dialects are provided only when NHibernate may need to directly use some new features of the newer database versions. By example, the 2012 dialect make use of offset fetch paging syntax, while previous versions are using the sub-query trick with row_number. (A lot of new features do not require any changes in NHibernate.)

The trouble with the driver is not related to the dialect version, but most likely to your application targeting .Net Core without taking a dependency on System.Data.SqlClient. The default driver for SQL Server depends on it, but under .Net Core, it is no more part of the base framework. You must add the package for it to your project. Normally the detail of the error raised by NHibernate allows to infer this, but you have not provided it.

Gregory

unread,
Apr 13, 2021, 7:36:31 AM4/13/21
to nhusers
  Thank you. Adding the requisite package solved the issue. To anyone reading this in the future, I used System.Data.SqlClient (4.6.1) for ASP.NET Core 3.0.  
Reply all
Reply to author
Forward
0 new messages