如何让 Nhibernate 重建数据库?

How to get Nhibernate to rebuild Database?

问题

当我在映射中添加新字段时,如何强制 Nibernate 重建数据库并添加新字段?

目前,如果我在映射 XML.

中更改 table 的名称,它只会重建 table

我的映射XML

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" auto-import="true" assembly="HibernateTest" namespace="HibernateTest.Models">
  <class name="Employee" table="Employee2" dynamic-update="true" xmlns="urn:nhibernate-mapping-2.2">
    <cache usage="read-write"/>
    <id name="Id" column="Id" type="int">
      <generator class="native" />
    </id>
    <property name="FirstName" />
    <property name="LastName" />
    <property name="Designation" />
    <property name="SecondDesignation" />
  </class>
</hibernate-mapping>

您需要使用 SchemaExport。 您可以在此处查看文档 http://nhibernate.info/doc/nhibernate-reference/toolsetguide.html#toolsetguide-s1