从 NHibernate 配置文件生成数据库 [英] Generate Database from NHibernate config files

查看:30
本文介绍了从 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...)

推荐答案

正如 Joachim 所提到的,这是您正在寻找的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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆