Nhibernate模式导出
我在SQL Server中创建了一个数据库,我想使用C#中的Nhibernate导出模式。我有两个类叫做Nhibernate模式导出,nhibernate,Nhibernate,我在SQL Server中创建了一个数据库,我想使用C#中的Nhibernate导出模式。我有两个类叫做Customer和Address customer.cs: public class Customer { public int ID {get; set;} public Address Address1 { get; set; } public Address Address2 { get; set; } } public class Address {
Customer
和Address
customer.cs:
public class Customer
{
public int ID {get; set;}
public Address Address1 { get; set; }
public Address Address2 { get; set; }
}
public class Address
{
public string City{get;set;}
public string Postcode{get;set;}
}
地址。cs:
public class Customer
{
public int ID {get; set;}
public Address Address1 { get; set; }
public Address Address2 { get; set; }
}
public class Address
{
public string City{get;set;}
public string Postcode{get;set;}
}
我已经编写了customer.hbm.xml
。我将地址定义为组件:
<component name="Address1" class="Address">
<property name="City" />
<property name="Postcode" />
</component>
当我的类是这样时,如何导出模式?您可以使用SchemaExport
class导出SQL模式
new SchemaExport(cfg).create(false, true);
我使用SchemeExport来完成这项工作。但是我没有将组件(地址)值作为字段来获取,因此映射文件存在问题。如果您也包含了映射文件,则可能会有所帮助。