基于 Fluent NHibernate 映射生成数据库全结构的方法

发布于 2024-08-28 10:24:56 字数 236 浏览 2 评论 0原文

我正在寻找基于 NHibernate 映射数据生成应用程序数据库完整结构的方法。这个想法是为用户提供一个选项来提供数据库连接字符串,然后使用应用程序所需的结构构建数据库。

数据库需要独立——这意味着它需要与 NHibernate 支持的任何数据库一起工作。

通过完整结构我的意思是我还想生成索引字段以及表之间的关系。

他们用 NHibernate 实现这一目标的方法很少吗?是吗,它们是什么?

I'm looking for ways to generate the application database full structure based on the NHibernate mapping data. The idea is to give the user an option to supply a database-connection string and then to build their a database with the structure that the application needs.

The database need to independent - it means that it needs to work with any database that are supported by NHibernate.

By full structure I mean that I want to generate also the index fields, and the relationship between tables.

Is their few ways to accomplish this with NHibernate? Is so, what are they?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

朕就是辣么酷 2024-09-04 10:24:56

您使用 SchemaExport 为此目的而设计的类。该 API 有点奇怪,但仍然有效。

You use the SchemaExport class for this purpose. The API is a little odd but it works nonetheless.

愿与i 2024-09-04 10:24:56

您可以使用 FNH 自动映射从 C# 类生成完整的数据库 - 我已经在我的项目中这样做了几个月,我喜欢它!

它足够强大,可以自动映射深度嵌套的对象图,包括对象列表。

它为您创建所有关系,但(至少对于 SQLite 来说)不是索引。

有关详细信息,请参阅 http://wiki. Fluentnhibernate.org/Auto_mapping

请参阅 http://fnhsamples.codeplex.com/ 了解完整的工作示例,由 Nikola Malovic 提供。

You can generate a full database from your C# classes using FNH automapping - I've been doing it on my project for several months now, and I love it!

It's powerful enough to automatically map a deeply nested object graph, including Lists of objects.

It creates all the relationships for you, but - for SQLite, at least - not the indexes.

See http://wiki.fluentnhibernate.org/Auto_mapping for more info.

See http://fnhsamples.codeplex.com/ for a fully working example, kindly provided by Nikola Malovic.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文