【问题标题】:How to get Nhibernate to rebuild Database?如何让 Nhibernate 重建数据库?
【发布时间】:2015-12-23 21:09:18
【问题描述】:

问题

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

目前,如果我在映射 XML 中更改表的名称,它只会重建表。

我的映射 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>

【问题讨论】:

    标签: c# sql-server nhibernate orm nhibernate-mapping


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2011-08-31
      • 2018-08-29
      • 1970-01-01
      • 1970-01-01
      • 2013-05-22
      • 2014-08-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多