Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you check if a table exists with NHibernate(or Fluent)?

Whats the best, most consistent way to check if a table exists in NHibernate (or with Fluent-NHibernate)?

Is it even possible? I mean it seems like a simple task for such a heavy-duty ORM.

Also on a related question, can you check if a set of tables or a whole schema exists with NHibernate?

like image 800
Mark Rogers Avatar asked Oct 12 '09 21:10

Mark Rogers


People also ask

What is the difference between NHibernate and fluent NHibernate?

Fluent NHibernate offers an alternative to NHibernate's standard XML mapping files. Rather than writing XML documents, you write mappings in strongly typed C# code. This allows for easy refactoring, improved readability and more concise code.


1 Answers

If you store you NHibernate configuration somewhere or do it before you build your session factory it is possible to validate the generated schema against the database.

    public void ValidateSchema(Configuration config)
    {
        new SchemaValidator(config).Validate();
    }
like image 60
mhenrixon Avatar answered Oct 25 '22 16:10

mhenrixon