C# NHibernate能否从现有类自动创建表?

C# NHibernate能否从现有类自动创建表?,c#,nhibernate,C#,Nhibernate,在这方面我是个新手,但我需要从现有类创建新表,而不需要手动创建它们。这可以使用工具或命令行完成吗?是的,使用nhibernate可以自动生成和更新架构 var cfg = new Configuration(); cfg.Configure(); cfg.AddAssembly(typeof (aClassFromYourProject).Assembly); new SchemaExport(cfg).Execute(false, true, false, false); 更新

在这方面我是个新手,但我需要从现有类创建新表,而不需要手动创建它们。这可以使用工具或命令行完成吗?

是的,使用nhibernate可以自动生成和更新架构

var cfg = new Configuration();  
cfg.Configure();  
cfg.AddAssembly(typeof (aClassFromYourProject).Assembly);  
new SchemaExport(cfg).Execute(false, true, false, false); 
更新:SchemaExport.Execute的重载选项在3.x版本中已更改。最后一个论点不再需要了

new SchemaExport(cfg).Execute(true, true, false);

在不清除所有当前数据的情况下,是否仍可以执行此操作?