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

查看:83
本文介绍了哪些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映射到

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.

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

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天全站免登陆