How to map SQL Server `varbinary (max)` field to NHibernate ByCode mapping?

I have a class with a type property byte[]that I would like to map to a field varbinary(max)in SQL Server using the new NHibernate ByCode mapping.

So far, using SchemaAction = SchemaAutoAction.RecreateNH to create the schema, I got the following (the name of the class property is "Data"):

  • When the match is not qualified in any way, I finish the field varbinary(8000)
  • When matching, map.Property(x => x.Data, m => m.Length(int.MaxValue))I get an “image” field (which, according to SQL Server docs, will not be supported in the next version of SQL Server)
  • When displaying map.Property(x => x.Data, m => m.Type(TypeFactory.GetBinaryType(int.MaxValue)), I get a field varbinary(8000)that just seems wrong

What am I missing?

+3
source share
1 answer

I had the same problem and it worked for me.

Property(e => e.Data, m => m.Column(cm => cm.SqlType("varbinary(MAX)")));
+2
source

All Articles