Here is the working code.
private static ISessionFactory CreateSessionFactory()
{
try
{
var cfg = OracleClientConfiguration.Oracle10.ConnectionString(c =>
c.Is("Data Source=XXXXXXX;User ID=XXXXX;Password=XXXX;"));
FluentConfiguration configuration = Fluently.Configure()
.Database(cfg)
.Mappings(m => m.AutoMappings.Add(CreateAutomappings))
.ExposeConfiguration(x => x.SetProperty("hbm2ddl.keywords", "auto-quote"))
.ExposeConfiguration(BuildSchema);
return configuration.BuildSessionFactory();
}
catch (Exception ex)
{
Console.WriteLine(ex.InnerException.Message);
throw ex;
}
}
Remember.. You still need to limit the column length to 30 characters. I have modified the IColumnInstances to add ColumnName method and added a Convention. Here is the code for that
Add this code in ColumnInstance class of FluentNHibernate. I have also added the respective interface methods.
public void ColumnName(string columnname)
{
mapping.Set(x => x.Name, Layer.Conventions, columnname);
}
Add this implementation code in your code.
public class ColumnNameConvention : IColumnConvention, IColumnConventionAcceptance
{
public void Accept(IAcceptanceCriteria<IColumnInspector> criteria)
{
criteria.Expect(x => x.Name.Length > 30);
}
public void Apply(IColumnInstance instance)
{
try
{
instance.ColumnName(instance.Name.Substring(instance.Name.Length - 25, 25));
}
catch (System.Exception ex)
{
throw ex;
}
}
}