哪些 ORM 框架将为您构建和执行 SQL DDL?

发布于 2024-11-30 14:10:18 字数 175 浏览 1 评论 0原文

如果数据库不存在,Entity Framework Code First 将为您构建数据库,并根据您的映射对象构建数据库。我相信 Roundhouse 会使用 NHibernate 对 Fluent 映射文件做同样的事情。

是否有其他 ORM(或 Roundhouse 等工具)可以处理所有 SQL DDL 创建和执行?

Entity Framework Code First will build the database for you if it doesn't exist and structure it based on your mapping objects. I believe Roundhouse will do the same thing with Fluent Mapping files using NHibernate.

Are there any other ORM's (or tools like Roundhouse) that will take care of all your SQL DDL creation and execution?

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

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

发布评论

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

评论(2

场罚期间 2024-12-07 14:10:18

NHibernate 不需要到 生成数据库架构。此功能内置于 NHibernate 核心中:

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

然而,根据我的经验,这对于内存中集成测试或初始部署最有用。生产数据库需要升级。如果您坚持下去,那么您将需要添加和删除列、表和外键而不影响数据。它具有连续性和版本控制方面。 NHibernate 只知道您的当前映射。例如,它不知道两个月前您将客户的名字和姓氏存储在名为“CustomerName”的列中,然后您决定将其拆分为两列“FirstName”和“LastName”(这可能是最原始的更改)可以制作)。 NHibernate 的工作是将当前模式映射到对象,而不是记住几年前的数据建模选择。

根据我的经验,没有神奇的工具可以编写升级脚本,它们必须手动编写或至少由开发人员审核。工具可以为您提供执行这些脚本的框架,例如 RoundhouseE。 Scott Allen 的优秀 关于“仅向前,运行一次”方法的系列

NHibernate does not need Fluent Mappings to generate database schema. This feature is built into the NHibernate core:

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

In my experience however this is mostly useful for in-memory integration tests or initial rollouts. Production databases need to be upgraded. If you stick around, then you will need to add and remove columns, tables and foreign keys without affecting data. There is a continuity and versioning aspect to it. NHibernate only knows your current mapping. It does not know for example that 2 months ago you stored your customer first and last name in column called "CustomerName" and then you decided to split this into two columns "FirstName" and "LastName" (which is probably the most primitive change that can be made). NHibernate job is to map your current schema to objects, not to remember data modeling choices from few years ago.

In my experience there is no magic tool that will write upgrade scripts, they have to be written manually or at least reviewed by developer. Tools can provide you a framework for executing these scripts, like RoundhouseE. Scott Allen has an excellent series about 'forward-only, run-once' approach.

安静被遗忘 2024-12-07 14:10:18

如果您在配置文件中将 hbm2ddl.auto 设置为 createcreate-dropupdate,hibernate 就会执行此操作。也就是说,使用 Java,我假设 nHibernate 也是如此。

如果 ORM 不执行 ddl,那么拥有它就没有多大意义,至少它是一个关键功能。恕我直言。

hibernate does if you set hbm2ddl.auto to create or create-drop or update in the config file. Using Java that is, I assume its the same for nHibernate.

If an ORM does not do ddl, there is not much point in having it, well its a key feature at least. Imho.

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