Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何让Nhibernate重建数据库? 问题:_C#_Sql Server_Nhibernate_Orm_Nhibernate Mapping - Fatal编程技术网

C# 如何让Nhibernate重建数据库? 问题:

C# 如何让Nhibernate重建数据库? 问题:,c#,sql-server,nhibernate,orm,nhibernate-mapping,C#,Sql Server,Nhibernate,Orm,Nhibernate Mapping,在映射中添加新字段时,如何强制Nibernate重建数据库并添加新字段 目前,只有在映射XML中更改表的名称时,它才会重建表 我的映射XML 您需要使用SchemaExport。 您可以在这里查看文档 <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" auto-import="true" assembly="HibernateTest" na

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

目前,只有在映射XML中更改表的名称时,它才会重建表

我的映射XML
您需要使用SchemaExport。 您可以在这里查看文档

<?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>