用NHibernate创建表 [英] Creating tables with NHibernate

查看:68
本文介绍了用NHibernate创建表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将NHibernate用于新的应用程序.目标是使用NH创建表.我有两个问题:

I am attempting to use NHibernate for a new application. The goal is to create tables with NH. I have two questions:

  1. 如果可以的话,该怎么做.

  1. How is this done, if it can be done.

这如何更改app.config中的配置部分?

How does this change my configuration section in the app.config?

推荐答案

听起来像您想要做的SchemaExport

示例:

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

cfg是您的NHibernate配置对象.

Where cfg is your NHibernate configuration object.

在NHibernate Forge文章的大约1/3处对此进行了很好的介绍: http://nhforge.org/wikis/howtonh/your-first-nhibernate-based-application.aspx

This is covered well about 1/3 of the way down on this NHibernate Forge article: http://nhforge.org/wikis/howtonh/your-first-nhibernate-based-application.aspx

他们阅读的文字:

第四行代码使用的SchemaExport帮助器类 NHibernate自动神奇地"在数据库中生成架构以用于 我们. SchemaExport将在数据库中创建产品表,然后 每次调用它都会删除表格和表格数据,并且 重新创建它.

The fourth line of code uses the SchemaExport helper class of NHibernate to auto-"magically" generate the schema in the database for us. SchemaExport will create the product table in the database and each time you call it it will delete the table and the table data and recreate it.

这篇关于用NHibernate创建表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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