Is it possible to create a database using NHibernate?

后端 未结 6 1390
一向
一向 2020-12-08 08:56

I am using NHibernate with FluentNHibernate for my DAL. I am also using SchemaExport and SchemaUpdate to create and update my database schema.

6条回答
  •  失恋的感觉
    2020-12-08 09:02

    No, NHibernate will not create the database for you. Creating databases is something you usually don't want do be done on the fly. It needs many configuration parameters and this is very database specific, even database version specific.

    For our product, I wrote a class that sets up the database. It is used for the installer, the integration tests and the database maintenance tool.

    • NHibernate creates the connection using its configuration.
    • my own implementation creates the database. There are different implementations for different dialects.
    • NH creates the tables and other database objects
    • Installer classes create initial data

    There is also a special case, where a customer doesn't want to grant the right to create databases. Then we expect him to do it and skip this part.

提交回复
热议问题