生成NHibernate的配置文件数据库 [英] Generate Database from NHibernate config files
本文介绍了生成NHibernate的配置文件数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有可能生成NHibernate的配置文件数据库表和C#类?之后,是有可能改变的配置文件,并更新表和配置文件非破坏性?
Is it possible to generate the database tables and c# classes from NHibernate config files? Afterwards, is it possible to change the config files and update the tables and config files non-destructively?
你推荐任何工具来做到这一点? (最好是免费的...)
Do you recommend any tools to do this? (preferably free...)
推荐答案
正如勒夫所说,这是hbm2ddl.auto设定你要寻找对于
As mentioned by Joachim, it's the "hbm2ddl.auto" setting that you're looking for.
您可以通过如下代码设置:
You can set it by code like this:
var cfg = new NHibernate.Cfg.Configuration();
cfg.SetProperty("hbm2ddl.auto", "create");
cfg.Configure();
和您还可以设置它在你的App.config文件:
And you can also set it in your App.config file:
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="hbm2ddl.auto">create</property>
这篇关于生成NHibernate的配置文件数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文