Fluent NHibernate - Dialect does not support DbType.Xml (SQLite)

I have my own NHibernate XML type (converts POCO to XML on the fly), so I can save objects to the database.

This works with SQL Server 2014 without any problems. However, when I try to run our unit tests that use SQLite, I get a lot of errors because of this.

System.ArgumentException: Dialect does not support DbType.Xml Parameter name: typecode.

I am using a custom type similar to what was mentioned here: How to map XML type columns to a strongly typed property of an object with NHibernate?

Now I need to figure out how to make this type work with SQLite.

What I've done:

-When registering SQLiteConfiguration, I specify a custom Dialect that registers an XMl ColumnType:

Configuration config = null; var db = SQLiteConfiguration.Standard.ConnectionString(_connectionString).ShowSql().Dialect("InvestX.Data.nHibernate.DbContext.SQLiteDialectWithManifestTyping"); _sessionFactory = new DbSessionFactory(Fluently .Configure() .Database(db) .Mappings(m => m.FluentMappings.Conventions.AddFromAssemblyOf<EnumConvention>()) .Mappings(m => m.FluentMappings.AddFromAssembly(Assembly.GetExecutingAssembly())) .ExposeConfiguration(c => config = c) .BuildSessionFactory()); 

...

 base.RegisterColumnType(System.Data.DbType.Xml, "Xml"); 

-Make sure that XmlType returns the SQL type of the SQL type

It works great on SQL Server 2012, but is struggling with SQLite.

Other thoughts I had success by manually adding an XML type column to my database using ALTER SCRIPT, and then changing my NHibernate binding to the binding as nvarchar (MAX). This works in all scenarios unless my system needs to create a new database from scratch. This is a temporary solution (that is, the most permanent solution), so I am not a big fan of it.

Any thoughts?

+7
c # xml sqlite nhibernate fluent-nhibernate
source share

No one has answered this question yet.

See similar questions:

5
How to map XML type columns to strictly typed object category with NHibernate?
0
How to write your own nHibernate dialect?

or similar:

2847
Improve SQLite performance per second per second?
1031
How to list tables in a SQLite database file that was opened using ATTACH?
851
How to check SQLite, does a table exist?
one
is it possible to use sqlite manifest display functions in nhibernate?
0
GUID connection to Sqlite UniqueIdentifier causing query errors in NHibernate
0
Fluent NHibernate Mapping XDocument Property to Oracle XMLType
0
NHibernate: Modifying XML / XDoc Mappings for In-memory SQLite Databases
0
nHibernate Support for foreign keys using SQLite
0
Fluent Nhibernate In Memory DB Testing with SQLite - Syntax Error calling user function in Select statement
0
Alternative displays for different dialects

All Articles