When ever you set a string value in fluent NHibernate it alwasy sets the DB vales to Nvarchar(255), I need to store quite a lot of long string which are based on user inputs
Hi I came across this Question, with the same problem. I have an slightly safer way of doing it as I don't want all string fields to have 10000 chars by default.
Firstly I register fluent nhibernate with some overrides
...//snip
....Mappings(m => m.AutoMappings.Add(
AutoMap.AssemblyOf()
//Use my mapping overrides here
.UseOverridesFromAssemblyOf()
.Conventions.Add(new MyConventions()).IgnoreBase
))
My Mapping override class looks like this:
public class MyMappingOverride : IAutoMappingOverride {
public void Override(AutoMapping mapping) {
mapping.Map(x => x.LongName).Length(765);
}
}
This is only required for small subset of entities with long text values. Maybe some else will find this useful?