Prefix string for ALL generated table names - FluentNHibernate

Is there an easy way to prefix all generated table names with a string?

Agreement

Table.Is(x => "Prefix" + x.EntityType.Name)

only works for Entity tables (doesn't work for join or subclass tables)

I cannot find a simple way to have every single table that nhibernate creates, with a prefix for a specific row without first defining all the cases that would create the table and define a rule for each case. Eah!

+3
source share
1 answer

for this you need to implement IHasManyToManyConventionand IJoinedSubclassConventionsee

public class SubclassConvention : IJoinedSubclassConvention, IHasManyToManyConvention
{
    public void Apply(IJoinedSubclassInstance instance)
    {
        instance.Table("Prefix" + instance.Type.Name);
    }

    public void Apply(IManyToManyCollectionInstance instance)
    {
        instance.Table("Prefix" + instance.TableName);
    }
}
+1
source

All Articles