哪些 ORM 框架将为您构建和执行 SQL DDL? [英] Which ORM frameworks will build and execute the SQL DDL for you?

查看:21
本文介绍了哪些 ORM 框架将为您构建和执行 SQL DDL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

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

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

推荐答案

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

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);

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

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.

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

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.

这篇关于哪些 ORM 框架将为您构建和执行 SQL DDL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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