Entity Framework 4.0 features)

Source: Internet
Author: User
Lastly, this chapter is going to briefly cover some of the new features in version 4.0 of the entityframework. there are a lot of new features and enhancements, but these next few pages will highlightsome of the most requested and needed features. following are some of the more important features and enhancements to be aware. some saw thelack of some of these features in the first version of the Entity Framework as a notable variable coming. • Plain old CLR objects (POCO) Support • Model-First Support • Deferred loading of related objects • Functions in LINQ to entities queries

• Plurality naming support

• Complex Type Support

• Customized object Layer Code Generation

• Model Browser improvements

The following sections will briefly discuss each item. A more detailed discussion of each item is

Written ded throughout the book.

 

Poco support

One of the more powerful new features of the Entity Framework is the ability to add and use your own

Custom Data classes in conjunction with your data model. This is accomplished by using CLR objects,

Commonly known as "poco" (plain old CLR objects). The added benefit comes in the form of not

Needing to make additional modifications to the data classes. This is also called persistence-ignorance.

The flexibility of extending these partial classes means more control over the core entity object

Functionality. This is a huge advantage as developers can now leverage and preserve valuable

Customizations and business logic, which they might not have been able to do previusly.

Model-First Support

In the first version of the Entity Framework, developers cocould create a conceptual model using

Create Database Wizard, but that model cocould not be persisted (created) based on that model. This

Changes with the ADO. Net 4.0 Entity Framework.

When creating your initial conceptual model via the create database wizard you can now create

Database Based on the conceptual model. This is a huge plus for developers who like to create the object

Model first and generate the database based on the model. This functionality supports the data-driven

Design that the EDM is purely based on.

Related Object-deferred Loading

Deferred loading is also known as lazy loading, and in the first version of the Entity Framework, related

Objects were not automatically loaded from the data source as navigation properties were accessed.

In ADO. Net 4.0 Entity Framework, query results can be shaped by composing queries that explicitly

Navigate the relationships via the navigation properties.

LINQ-to-entities Function Support

 

Function Support in the first version of the Entity Framework was limited. A function represented either

A stored procedure or a UDF in the database.

Two new classes have been added to the Entity Framework for this release to address this issue,

Entityfunctions and sqlfunctions classes. These classes provide developers the ability to access

Canonical and database functions via LINQ to entities queries.

Additionally, a new attribute called edmfunctionattribute gives the Entity Framework the ability

Use a CLR method to serve as a proxy for a function defined in the conceptual model.

 

Plurality naming
One of the big complaints in the first version of the Entity Framework was how naming conventions
Were applied to EDM objects such as entities and navigation properties when using the model wizards.

 The first version of the Entity Framework gave the entity name and the entity set name the same name.

There was no attempt to singularize or pluralize names when generating a model from a database.

The problem is that this caused some confusion when referencing the database table or entitytype

In code. For example, if your database has a table called employees, then you will also get an entitytype

Called employees as well. This causes confusion about whether you are referencing the table or

Entitytype, such as in the code fragment below.

Customers customer = new customers ();

Luckily, this issue has been addressed. The model wizards, both the Entity Data Model and update

Model wizards, now provide the option of using singular or plural forms of names for entities, Entity

Sets, and navigation properties.

The goal of this change was to make the application code much easier to read and avoid a lot of

Confusion between object names.

Complex types

A big addition to this version of the Entity Framework is the support for complex types. complex types

Are like entities in that they consist of a scalar property or one or more complex type properties. Thus,

Complex types are non-Scalar properties of entity types that enable Scalar properties to be organized

Within entities.

 

 

Customized object-Layer Code Generation

Object-Layer Code is generated, by default, by the EDM using the entity model Code Generator tool. This

Version of the Entity Framework allows developers to add text templates to a project that replaces

Default tool to generate the object-layer code.

By using custom text templates, the EDM will generate the object context and entity classes.

Entity Framework makes it very easy to add custom templates via the EDM.

Model Browser improvements

Several improvements have been made to the model browser that make working with the EDM much

More pleasant. Improvements include the following:

• Updating the model when changes are made to the underlying database.

• Deleting objects from the model.

• Searching for a specified string in the storage and conceptual models.

• Locating entity types on the design surface.

This list is by no means complete, as your more improvements have been made to the model

Browser

Back-end support

The great thing about the Entity Framework is that in essence it does not really care about the data store

From which the data is being queried. It doesn't need to. Neither the type of database nor the schema

Itself is completely unknown to the Entity Framework, and they will have no impact on your model.

Out of the box, the Entity Framework ships with two providers:

• Entityclient provider for the Entity Framework: used by Entity Framework

Applications to access data described in the EDM. This provider uses the. NET

Framework data provider for SQL Server (sqlclient) to access a SQL Server

Database.

• Net Framework data provider for SQL Server (sqlclient) for the entity

Framework: supports the Entity Framework for use with a SQL Server database.

The great thing about the Entity Framework is that it is database-, or data source-, independent, in

That you can create M providers to access other databases. For example, through third party

Providers you can access the following:

• Oracle

• MySQL

• PostgreSQL

• SQL Anywhere

• DB2

• Informix

• U2

• INGRES

• Progress

• Firebird

• Synergy

• Kerberoso

 This is quite a list and it shows you that the Entity Framework is gaining in popularity. This list is

No means complete, as providers are continuously being created by third-party vendors. At the time

This writing, a complete list of providers and their vendors can be found here:

Http://msdn.microsoft.com/en-us/data/dd363565.aspx

The great thing about this is that the provider does all of the work for you pertaining to query

Reshaping. You are responsible for providing the connection information to the specific data store,

The provider takes care of the rest when working with the Entity Framework. Why? Because of the need

To learn databases or figure out the nuances of different data stores. Instead, you use the entity

Framework's query syntax such as LINQ to entities or Entity SQL and forgo the headache

Remembering the database differences.

Through. NET Framework data provider for SQL Server (sqlclient) for the Entity Framework

You can use SQL Server as far back as version SQL Server 2000 up through SQL Server 2008. Microsoft

Even supports SQL Server compact edition.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.