Is there a simple way to prefix all generated table names with a string?
The convention
Table.Is(x => "Prefix" + x.EntityType.Name)
only works for Entity tables (doesn't function for join or subclass tables)
I can't seem to find a simple way to have every single table开发者_运维百科 that nhibernate creates be prefixed with a specific string without first identifying all the cases that would create a table and specifying a rule per case. Ew!
for this you have to implement IHasManyToManyConvention
and IJoinedSubclassConvention
see
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);
}
}
精彩评论