Tag Archives: NHibernate

SQL Server’s nvarchar(max) on Castle ActiveRecord

I’m using the new SQL Server 2005’s data type nvarchar(max) on a .Net project (ntext has been deprecated in this version) in conjuction with Castle ActiveRecord. For a complete integration (including schema creation), ActiveRecord property should looks like this:

[Property("description", ColumnType = "StringClob", SqlType = "nvarchar(MAX)")]

ColumnType = “StringClob” avoids text to be truncated if it gets too long. SqlType = “nvarchar(MAX)” forces the field to be created as that data type, otherwise, it will be created as nvarchar(255).

A more detailed explanation can be found here and here.