实体框架中仅代码模型的优点4? [英] Advantages of Code Only model in Entity Framework 4?

查看:140
本文介绍了实体框架中仅代码模型的优点4?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

实体框架4.0期货预览(CTP3)现在有一个代码建模范例,用于在您的类型和数据库之间进行映射。没有涉及到edmx文件,没有EDM设计师需要。



我想知道Code Only与Model First有什么优势?在Code First中可以做什么,在其他型号(First First& Database first)中无法做到这一点?我想可能更多的控制,但我不能修改CSDL,SSDL,MSL文件和我自己的代码,以获得我需要的结果。代码模型包括在可能容易出错的代码中执行所有操作,例如产生错误的所需模型或缺少属性定义。

解决方案

这真的是一个偏好的问题。引用EF设计博客:


然而,许多开发者将他们的
代码视为他们的模型。



理想情况下,这些开发人员只想要
编写一些Domain类,而不需要
即可触及一个设计器或
的一个XML可以使用
实体框架。基本上他们要
想写'只代码'。


http://blogs.msdn.com/b/efdesign/archive/2009/06/10/code -only.aspx


The Entity Framework 4.0 Futures preview (CTP3 now) has a code only modeling paradigm for mapping between your types and the database. No edmx files involved and no EDM designer needed.

I wanted to know what are the big advantages of Code Only vs Model First? What can be done in Code First which can't be done in other models (Model First & database first)? I am thinking maybe more control but I cant still modify the CSDL, SSDL, MSL files and my own code to get the result I need. The Code Only model involves doing everything in code which could be prone to errors like producing the wrong desired model or missing property definitions.

解决方案

It is really a matter of preference. Quoting the EF design blog:

However many developers view their Code as their model.

Ideally these developers just want to write some Domain classes and without ever touching a designer or a piece of XML be able to use those classes with the Entity Framework. Basically they want to write 'Code Only'.

http://blogs.msdn.com/b/efdesign/archive/2009/06/10/code-only.aspx

这篇关于实体框架中仅代码模型的优点4?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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