user3524095
user3524095

Reputation: 1

How to change Existing Database Table Name using NHibernate in c#

I am a biginner in NHibernate. I have already created Database tables using NHibernate mapping. Now I want change one of my Table Name and Column Name. I am unable to found the way to change the Table Name.

Please help me to resolve this issue.

Thanks in Advance.

Upvotes: 0

Views: 840

Answers (2)

Vasily Sliounaiev
Vasily Sliounaiev

Reputation: 463

NHibernate itself can generate some schema creation SQL but it does not generate SQL to alter the schema from the current configuration. George's answer applies to where the database schema is required to remain the same and NHibernate is used to map to that schema.

If you are looking to modify the schema throughout development you are probably looking for a tool like Fluent Migrator.

Upvotes: 0

user1413338
user1413338

Reputation:

What you need is something like this:

public class MyClassMap : ClassMap<MyClass>
{
    public MyClassMap()
    {
        Table("MyFancyClassTableName");
        Id(x => x.MyClassId);
        Map(x => x.MyClassType);
    }        
}

Upvotes: 1

Related Questions