how to create prefix database?

Jul 14, 2014 at 4:21 AM
in the DbConfiguration, how to create prefix database by NHibernate. thank you before
Coordinator
Jul 14, 2014 at 7:46 AM
Are you wanting to prefix all database tables or just a single Apps database tables?
Jul 14, 2014 at 9:04 AM
I want to prefix all database
Coordinator
Jul 14, 2014 at 9:09 AM
Edited Jul 14, 2014 at 9:12 AM
Add a class to your project like so:
public class TableNameConvention : IClassConvention, IHasManyToManyConvention
{
    public void Apply(IClassInstance instance)
    {
        instance.Table(GetTableName(instance.TableName));
    }

    public void Apply(IManyToManyCollectionInstance instance)
    {
        instance.Table(GetTableName(instance.TableName));
    }

    private static string GetTableName(string tableName)
    {
        return string.Format("MyTablePrefix_{0}", tableName.Replace("`", ""));
    }

}
And swap out MyTablePrefix_ with whatever you want your prefix to be.

Finally add
    public override IEnumerable<Type> Conventions
    {
        get { yield return typeof(TableNameConvention); }
    }
To in your AppClass. I.E CoreApp.cs or similar.
Marked as answer by tampro92 on 7/14/2014 at 2:33 AM
Jul 14, 2014 at 9:33 AM
thank you for your help,and if you can make add prefix database in the installation is good too