Using NHibernate with Azure SQL Edge not possible

157 views
Skip to first unread message

Sandro Lange

unread,
Nov 22, 2021, 9:55:23 AM11/22/21
to nhusers
Hello,

When we try to use Azure SQL Edge instead of MSSQL Server with NHibernate we always get:

SqlException: Common Language Runtime(CLR) is not enabled on this instance.

Why does NHibernate need CLR support and how to disable it? Azure SQL Edge does not support CLR and never will.

We just don't see why NHibernate would need it as it supports so many different databases and CRL is a very minor feature for SQL Server.

Any ideas?

Carlo Accorsi

unread,
Nov 25, 2021, 5:03:51 PM11/25/21
to nhusers
Some people on our team are attempting the same thing - and running into the same issue. 
The trouble is with underlying SQLClient that's issuing query using clr dependent function ASSEMBLYPROPERTY which is not supported in SQL Edge. 

https://github.com/dotnet/SqlClient/blob/main/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/SqlMetadataFactory.cs

It seems like there would be a technically equivalent way to perform this query without the function. 
Would be nice if the provider library was able to operate in an ANSI sql compatible manner if desired. 

This issue is related to this gentlemen's post as well. 


Roman

unread,
Dec 2, 2021, 5:23:47 AM12/2/21
to nhusers
It seems you can still use NHibernate by setting session factory setting hbm2ddl.keywords to "none" (disabling keywords import)

You can read more about this setting and all implications here   Auto Quote Table/Column names - NHibernate

Sandro Lange

unread,
Dec 2, 2021, 5:23:58 AM12/2/21
to nhusers
Thanks for the head up. It really seems to be related to the SQLClient and the function called in the GetReservedWords method in the MsSqlDataBaseSchema-class of NHibernate.
When creating a derived class and override this method (and of course use it in a custom MsSql-Dialect class) we can use Azure SQL Edge without a problem.

Like this:


You can use the dialect like this in your NHibernate configuration:

c.DataBaseIntegration(db => db.Dialect<EnhancedMsSql2008Dialect>());

while c is your NHibernate-Configuration object.

Note: you can also derive from MsSql2012Dialect - in our use case we have a specific need not to do it ;)

Reply all
Reply to author
Forward
0 new messages