What are the pros & cons of using Entity Framework 4.1 Code-first over Model/Database-first with EDMX diagram? 使用实体框架4.1代码优先于模型/数据库优先使用EDMX图表有什么优缺点? 数据库
I'm trying to fully understand all the approaches to building data access layer using EF 4.1. 我正在尝试彻底理解使用EF 4.1构建数据访问层的全部方法。 I'm using Repository pattern and IoC
. 我正在使用Repository模式和IoC
。 app
I know I can use code-first approach: define my entities and context by hand and use ModelBuilder
to fine-tune the schema. 我知道我能够使用代码优先方法:手动定义个人实体和上下文,并使用ModelBuilder
来微调模式。 框架
I can also create an EDMX
diagram and choose a code generation step that uses T4 templates to generate the same POCO
classes. 我还能够建立EDMX
图并选择使用T4模板生成相同POCO
类的代码生成步骤。 ui
In both cases I end up with POCO
object which are ORM
agnostic and context that derives from DbContext
. 在这两种状况下,我最终都获得了与ORM
无关的POCO
对象和源自DbContext
上下文。 spa
Database-first seems to be most appealing since I can design database in Enterprise Manager, quickly synch the model and fine-tune it using the designer. 数据库优先彷佛最吸引人,由于我能够在企业管理器中设计数据库,快速同步模型并使用设计器对其进行微调。 .net
So what is the difference between those two approaches? 那么这两种方法有什么区别? Is it just about the preference VS2010 vs Enterprise Manager? 是仅仅关于VS2010与企业管理器的偏好? 设计