NHibernate 3.0 binary data truncation

NHibernate 3.0.0 has a bug which silently truncates data going into varbinary(MAX) fields to 8000 bytes — not a pleasant one to find in production because your test documents weren’t big enough! This stackoverflow answer contains a workaround for hbm file mappings; translated to FluentNHibernate auto mapping it becomes:

var sessionFactory = Fluently.Configure()
    .Database(/* database config */)
    .Mappings(m => 
            .Override<Document>(map => 
                map.Map(d => d.Data).Length(2147483647))))

The bug is apparently fixed in 3.0.1.


NuPack Antlr 3.1.3 version mismatch

I installed FluentNHibernate & NHibernate.Core 3.0 Beta through the excellent NuPack. Attempting to run a Linq query against the session resulted in:

Could not load file or assembly ‘Antlr3.Runtime, Version=, Culture=neutral, PublicKeyToken=3a9cab8f8d22bfb7’ or one of its dependencies. The located assembly’s manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

It looks like the binary dll distributed in the Antlr 3.1.3 package is actually version 3.1.0. Downloading the correct version from here and copying over the top of the offending file (in <solution root>\packages\Antlr.3.1.3\lib) fixed the problem.