Fluent Nhibernate - How to specify table name

2019-05-10 17:54发布

问题:

I just started learning Nhibernate and Fluent Nhibernate. I want to specify table name when I create my mapping class.

Entity name in application is "CustomerOrders" but in the oracle database, table name is "CUSTOMER_ORDERS".

I learnt from googling that I can use "WithTable" to specify database table name.

I am not sure how to use it and where as Vs2008 didn't find the method.

Thanks

回答1:

WithTable was renamed to Table for the 1.0 release. It was mentioned in the release notes (first bullet point).



回答2:

public class CustomerOrdersMap : IAutoMappingOverride<CustomerOrders>
    {
        public void Override(AutoMapping<CustomerOrders> mapping)
        {
            mapping.Table("CUSTOMER_ORDERS");


        }
    }