在Vs 2008和2010中使用实体框架有什么区别 [英] What's Differences Between Using Entity Framework in Vs 2008 And 2010

查看:40
本文介绍了在Vs 2008和2010中使用实体框架有什么区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您首先知道Entity Framework是Visual Studio 2008 SP1附带的.现在,它随Visual Studio 2010一起提供.

You know firstly Entity Framework came with Visual Studio 2008 SP1. Now it is come with Visual Studio 2010.

问题是,这两个版本之间有什么区别?

The question is that, what are differences between these two version?

推荐答案

  1. 持久性无知:您可以定义自己的POCO(普通的旧CLR对象),该POCO与任何特定的持久性技术脱钩.这样,您可以在需要时将一个数据访问堆栈换成另一个.

  1. Persistence Ignorance: You can define your own POCO’s (Plain Old CLR Objects) that are decoupled from any specific persistence technology. This allows you to swap out one data access stack for another should the need arise.

T4代码生成:EF 4附带了许多T4代码生成模板,您可以自定义这些模板或将其替换为自己的模板.(T4是Visual Studio 2008或更高版本中内置的代码生成技术.)

T4 Code Generation: EF 4 will ship with a number of T4 code-generation templates which you can customize or replace with your own. (T4 is a code-generation technology built into Visual Studio 2008 or later.)

延迟加载:除了快速加载和显式加载外,还可以根据需要自动加载相关实体.例如,对于具有OrderDetails属性的Order类,将该属性标记为虚拟将导致在枚举OrderDetails属性时自动从数据库中加载订单详细信息.

Lazy Loading: In addition to eager and explicit loading, related entities can be loaded automatically on demand. For example, with an Order class that has an OrderDetails property, marking this property as virtual will cause order details to be loaded from the database automatically when the OrderDetails property is enumerated.

POCO更改跟踪:EF4将支持两种模型来跟踪POCO的更改.默认情况下,EF将对对象的原始状态进行快照,然后在保存更改时将其与当前版本进行比较.另外,您可以将属性定义为虚拟属性,以便不断跟踪其状态并与对象状态管理器保持同步.

POCO Change-Tracking: EF4 will support two models for tracking changes on POCO’s. By default EF will take a snapshot of the original state of your objects and then compare it to the current version when saving changes. Alternatively, you can define properties as virtual so that their state is continually tracked and kept in sync with the object state manager.

具有自我跟踪实体的更好的N层支持:EF4的第一个CTP包含一个T4模板,用于生成可在客户端上跟踪其自身更改的实体,然后在跨服务边界发送并保存到时将其序列化数据库.

Better N-Tier Support with Self-Tracking Entities: The first CTP for EF4 includes a T4 template for generating entities that track their own changes on the client, which are then serialized when sent across service boundaries and saved to the database.

模型优先开发:为您的实体创建一个模型,然后让Visual Studio 2010生成DDL以创建具有匹配表和关系的数据库.

Model-First Development: Create a model for your entities, then have Visual Studio 2010 generate DDL to create a database with matching tables and relations.

仅代码开发:编写类并让EF推断概念模型(没有edmx文件!).您甚至可以从动态模型生成DDL以创建数据库和表.

Code-Only Development: Write classes and have EF infer a conceptual model (no edmx file!). You can even generate DDL from the dynamic model to create the database and tables.

引自 DevelopMentor

查看全文

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