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

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

问题描述

您首先了解Visual Studio 2008 SP1中的实体框架。现在来自Visual Studio 2010。



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

解决方案


  1. 持续性无知:您可以定义自己的POCO(普通老CLR对象),它们与任何特定的持久性技术脱钩。


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


  3. Lazy Loading:除了热切和明确的加载外,相关实体可以按需自动加载例如,对于具有OrderDetails属性的Order类,将此属性标记为virtual将会在OrderDetails属性枚举时自动从数据库加载订单明细。


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


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


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


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


引自 DevelopMentor



EF中的新功能/ a>


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. 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.

  2. 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.)

  3. 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.

  4. 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.

  5. 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.

  6. 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.

  7. 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.

cited from DevelopMentor

what's new in EF

这篇关于在2008年和2010年间使用实体框架有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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