public void Alter(AutoPersistenceModel model) { var methods = model.GetType().GetMethods(); var method = methods.Single(x => x.Name == "Override" && x.GetGenericArguments().Any()); foreach (var type in _hasDocumentsIndexes) { // model.Override<{TIndex}>() var genericMethod = method.MakeGenericMethod(type); var alterationType = typeof(AlterationHelper <>).MakeGenericType(type); var overrideMethod = alterationType.GetMethods().Single(x => x.Name == "Override"); var alteration = overrideMethod.Invoke(null, null); genericMethod.Invoke(model, new[] { alteration }); } // automatically creates a database index on properties with the [Indexed] attribute model.Conventions.Setup(s => s.Add <IndexedPropertyConvention>()); // configure the size of the column model.Conventions.Setup(s => s.Add <StringColumnLengthConvention>()); }