I have a class with a property of type byte[] that I would like to map to a varbinary(max) field in SQL Server using the new NHibernate ByCode mapping.
So far, using SchemaAction = SchemaAutoAction.Recreate in order to have NH create the schema, I've ended up with the following (the class property name is "Data"):
varbinary(8000) fieldmap.Property(x => x.Data, m => m.Length(int.MaxValue)), I end up with an 'image' field (which, according to SQL Server docs, will not be supported in the next release of SQL Server)map.Property(x => x.Data, m => m.Type(TypeFactory.GetBinaryType(int.MaxValue)), I end up with a varbinary(8000) field, which just seems wrongWhat am I missing?
I experienced the same problem and this has worked for me.
Property(e => e.Data, m => m.Column(cm => cm.SqlType("varbinary(MAX)")));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With