I have the following convention that I load into my FNH configuration
public class TableNameConvention : IClassConvention, IClassConventionAcceptance { public void Accept(IAcceptanceCriteria<IClassInspector> criteria) { criteria.Expect(x => x.TableName, Is.Not.Set); } public void Apply(IClassInstance instance) { var tableName = instance.EntityType.Name.Pluralise(); instance.Table(tableName); } }
I do not specify table names in any of my mappings, but this convention does not apply. I am using Fluent NHibernate 1.4.1.1. Can someone discover something that I might have done wrong?
UPDATE
Agreements are downloaded as follows:
public static NHibernate.Cfg.Configuration BuildConfiguration() { var connectionStringName = "mydb"; return Fluently.Configure(new NHibernate.Cfg.Configuration()) .Database(MsSqlConfiguration .MsSql2008.ConnectionString(c => c.FromConnectionStringWithKey(connectionStringName)) .Dialect<MsSql2008Dialect>() .AdoNetBatchSize(50)) .Mappings(m => { m.FluentMappings.AddFromAssemblyOf<Profile>(); m.FluentMappings.Conventions.Add(DefaultLazy.Always(), DynamicUpdate.AlwaysTrue(), DynamicInsert.AlwaysTrue()); m.FluentMappings.Conventions.AddFromAssemblyOf<HiLoConvention>(); }) .ExposeConfiguration(config => config.SetProperty(NHibernate.Cfg.Environment.CurrentSessionContextClass, typeof(ManagedWebSessionContext).AssemblyQualifiedName)) .ExposeConfiguration(HiLoConvention.CreateScript) .ExposeConfiguration(RunSchemaUpdate) .BuildConfiguration(); }
All conventions are hosted in the same assembly and namespace as HiLoConvention, mentioned above in the call to the .AddFromAssembly () method.
UPDATE 2:
The problem is the Accept () method, because if I remove this method (as well as the IClassConventionAcceptance interface from the class declaration), then the convention will be applied. I also tried this wait to no avail
criteria.Expect(x => string.IsNullOrEmpty(x.TableName))
Source code worked with Fluent 1.2.1 ...
source share