Changing the Nhibernate entity to point to new table
I am using FLH and recently I changed the name of the table. I dont want to propagate the changes all the way across my layers. Is there a way, where I can retain the same entity name and just change the mapping. For example, my current entity name is Issuer and the table name is also issuer. However, the table name is changed to "counterparty" and I want to retain the entity name as Issuer. How can I achieve this?
I found the answer for the above problem. I made use of IAutomappingOverride
interface.
The sample code is below
public class IssuerMap :开发者_运维知识库 IAutoMappingOverride<Issuer>
{
public void Override(AutoMapping<Issuer> mapping)
{
mapping.Table("Counterparty");
}
}
Also found some related links Fluent Nhibernate - How to specify table name
You would need to have a Table("Counterparty")
clause in your classmap, as in How to specify table name in Fluent NHibernate ClassMap class?
精彩评论