2

I tried to change the table and column names of my Employee entity by accessing the Table("") and Column("") attributes of its classmap in fluent Nhibernate.

public class EmployeeMap : ClassMap<Employee>
{
    public EmployeeMap()
    {
        Table("Employees");
        Id(x => x.Id);
        Map(x => x.FirstName)
           .Column("EmpFirstName");
        Map(x => x.LastName);
           .Column("EmpLastName")
        References(x => x.Store);
     }
 }

But instead of having the names I specified, the table and column names that appeared in my Postgresql db are all in lower case i.e. Employees -> employees and EmpFirstName -> empfirstname.

How can I set my table and column names to have the exact letter cases that I specified in my employee mapping?

Thanks, Mark

2 Answers2

3

I prefer Sly's answer but you can get away with this (but it's ugly):

public class EmployeeMap : ClassMap<Employee>
{
    public EmployeeMap()
    {
        Table("Employees");
        Id(x => x.Id);
        Map(x => x.FirstName)
           .Column("\"EmpFirstName\"");
        Map(x => x.LastName);
           .Column("\"EmpLastName\"")
        References(x => x.Store);
     }
 }

EDIT here is link how to implement this via a naming strategy: http://manfredlange.blogspot.com/2011/04/fluent-nhibernate-postgresql-and.html

whosrdaddy
  • 11,720
  • 4
  • 50
  • 99
2

Try to setup autoquote option for NHibernate.

<property name="hbm2ddl.keywords">auto-quote</property>

My gues the problem is in this:

the identifiers FOO, foo, and "foo" are considered the same by PostgreSQL, but "Foo" and "FOO" are different from these three and each other.

Sly
  • 15,046
  • 12
  • 60
  • 89
  • @OP : look here how to implement this in FNH -> http://stackoverflow.com/questions/2438491/fluent-nhibernate-and-postgresql-schemametadataupdater-quotetableandcolumns-s – whosrdaddy Nov 28 '11 at 15:24