Fluent NHibernate - Create database schema only if not existing

前端 未结 2 1566
野的像风
野的像风 2021-02-02 07:23

I have an application where I use Fluent Nhibernate to create my database. This far I\'ve been recreating the database schema each time. The code that does this is this:

<
2条回答
  •  温柔的废话
    2021-02-02 08:00

    UPDATED (thanks dotjoe)

    Hbm2ddl is only capable of doing a schema diff and only updating what has changed with the SchemaUpdate class. However this class is pretty rudimentary in that it only takes a look at the current entities and how the schema differs. If significant changes have been made (ie entities removed or link tables removed) it won't be able to figure that out.

    On an earlier project we used hbm2ddl, however we've since moved onto use Fluent Migrator. I would say your best bet is to use a migration tool, like Fluent Migrator or Migrator.NET.

    http://github.com/schambers/fluentmigrator/

    http://code.google.com/p/migratordotnet/

提交回复
热议问题