The length of the string value exceeds the length configured in the mapping/parameter

This is a well known issue with NHibernate handling nvarchar(max), see :

http://geekswithblogs.net/lszk/archive/2011/07/11/nhibernatemapping-a-string-field-as-nvarcharmax-in-sql-server-using.aspx

For some years now, I have been file mapping nvarchar(max) columns to StringClob without encountering any problem :

<property name="myProp" column="MY_PROP" not-null="true" type="StringClob" access="property"></property>   

This link (from the comments) describes the fluent mapping required to fix this issue:

https://www.tritac.com/nl/blog/fluent-nhibernate-nvarchar-max-fields-truncated-to-4000-characters/

Map(x => x.Description).CustomType("StringClob").CustomSqlType("nvarchar(max)");

Leave a Comment