Difference between Entity Framework 3.5 and Entity Framework 4.0 (What's New in Entity Framework 4.0?)
The
first release of Entity Framework shipped in .NET Framework 3.5 SP1 and Visual
Studio 2008. Entity Framework 4 has been released as part of the release of
Visual Studio 2010 and .NET Framework 4.0.
Entity
Framework 4.0 builds on Entity Framework 3.5 in the following areas:
Multi-Targeting
Support: Entity
Data Model Designer and Entity Framework fully support Multi-Targeting
capabilities of VS 2010. You can use the designer to continue building your EF
3.5 applications or move forward to EF4. We take care of upgrading /
downgrading you to the right EDMX versions and such so that you can use a
single IDE to build apps using EF, regardless of the framework version you are
targeting.
Model-First
Development: In
addition to the Database-First approach you had in EF 3.5, Entity Data Model
designer in Visual Studio 2010 includes Model-First capability to allow you to
start from a model, and generate database based on that model.
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.
Foreign
Key Associations:
EF4 includes a new type of association called Foreign Key Association. FK
associations allow you to include FK properties in your model and use those as
a basis for relationship between entities. Independent Associations from EF 3.5
are still supported but FK Associations will help simplify a few scenarios such
as data binding. You can now include foreign keys in your model should you
choose to do so.
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.
More
LINQ Operators in LINQ to Entities:
More LINQ operators are supported by EF4 such as Contains, Single,
SingleOrDefault and DefaultIfEmpty.
EntityDataSource
support for QueryExtender, POCO and FKs: EntityDataSource control now includes support for
ASP.NET QueryExtender and POCO entities. QueryExtender is a new addition to
ASP.NET, which allows you to have more control over the data retrieval query of
a Data Source while leveraging LINQ capabilities of EF.
Design-time
support for Complex Types (with refactoring): Entity Data Model Designer in VS 2010 lets you define
complex types, view complex types in the model explorer tree and refactor
existing properties into complex type.
Ad-hoc
native query support:
EF4 supports more ad-hoc query patterns that allow you to run a store query or
a command directly.
Customizable
Code-Generation:
EF4 leverages the T4 (Text Template Transformation Toolkit) code
generation templating engine in Visual Studio. You can now write your own
templates that specify exactly how you want code generation to happen; or you
can modify the built-in templates such as the Entity Object Code Generator or
Self Tracking Entities Code Generator templates.
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.
Application
Patterns and Testability:
EF4 includes an additional interface to help you to write testable code when
using the framework. In addition, we have made sure that use of patterns such
as Repository and UnitOfWork are possible.
Persistence
Ignorance & POCO:
EF4 allows developers to use their pure domain classes without needing to
implement interfaces that deal with persistence concerns. Dynamic proxies are
supported for lazy loading and efficient change tracking.
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.
Generated
SQL improvements for better performance and readability: EF4 includes a lot of optimizations
to the queries generated by EF such as removal of unnecessary joins, better
translations of certain functions, removal of unneeded levels of nesting, and
more.
Pluralization:
There is now
Singularization/Pluralization support such that reverse engineering existing
databases will result in models that have more meaningful names for entity
types, entity sets and relationships.
CreateDatabase
and DDL Provider Services:
EF4 includes APIs on ObjectContext that allow you to do database creation based
on a model. Provider writers can implement DDL generation capability in their
providers that can take advantage of this capability.
Model
Defined Functions LINQ support:
Model Defined Functions allow you to define composable functions in your model
using Entity SQL. You can also expose these functions such that they can be
used from LINQ.
ObjectMaterialized
event: Now you can
write logic that is executed immediately after an object has been materialized.
Comments
Post a Comment