Tuesday, November 16, 2010

ADO .NET Entity Framework

Hello Friends,

For Entity Framework Beginners, please review: Entity Framework Basics

We will have brief introduction on the Entity Framework in .Net Framework 4.0.
Let start with
Entity Framework Over View:
The Entity Framework is the new concept introduced by Microsoft in .Net Framework which allows developers to create the DataAccess applications by programming against a conceptual application model which is logical model instead of programming directly against a relational storage schema or Database. The goal is to decrease the amount of code and maintenance required for data-oriented applications. Basically ADO .NET Entity Framework divides the database model into three sub-models viz:
1. Conceptual Schema Definition Language(CSDL)
2. Store Schema Definition Language(SSDL)
3. Mapping Specification Language(MSL)
Before discussing further about the three sub models lets discuss why Entity Framework is a better option than the traditional approach.

Entity Framework Vs Traditional ADO .NET:One can write code against the Entity Framework and the system will automatically produce objects as well as track changes on those objects and simplify the process of updating the database. The EF can therefore replace a large chunk of code a developer would otherwise have to write and maintain. Further, because the mapping between the objects and the database is specified declaratively instead of in code, if there is a need to change the database schema, a developer can minimize the impact on the code he has to modify in the applications--so the system provides a level of abstraction which helps isolate the application from the database. Finally, the queries and other operations written into the code are specified in a syntax that is not specific to any particular database vendor--in ADO.NET prior to the EF, ADO.NET provided a common syntax for creating connections, executing queries and processing results, but there was no common language for the queries themselves; ado.net just passed a string from the program down to the provider without manipulating that string at all, and if there was a need to move an app from Oracle to SQL Server, one would have to change a number of queries. So the developers must become SQL experts to build advanced queries. With the EF, the queries are written in LINQ or Entity SQL and then translated at runtime by the providers to the particular back-end query syntax for that database.
Together with LINQ to SQL (L2S), LINQ to Entities (L2E) and EF are currently the best data access API that Microsoft offers. They are way better than 'traditional' ADO.NET for most scenarios.

Now let’s discuss the three sub-models:
CSDL :
CSDL is the Entity Framework's implementation of the Entity Data Model. It is an XML based language that describes the entities, relationships, and functions that make up a conceptual model of a data-driven application.

CSDL Specification:Conceptual schema definition language (CSDL) is an XML-based language that describes the entities, relationships, and functions that make up a conceptual model of a data-driven application. This conceptual model can be used by the Entity Framework or ADO.NET Data Services. The metadata that is described with CSDL is used by the Entity Framework to map entities and relationships that are defined in a conceptual model to a data source. CSDL is the Entity Framework's implementation of the Entity Data Model.
In an Entity Framework application, conceptual model metadata is loaded from a .csdl file (written in CSDL) into an instance of the System.Data.Metadata.Edm.EdmItemCollection and is accessible by using methods in the System.Data.Metadata.Edm.MetadataWorkspace class. The Entity Framework uses conceptual model metadata to translate queries against the conceptual model to data source-specific commands. In the .edmx file, under the following tag one can view the CSDL contents:

SSDL :It is a XML based language that describes the storage model of an Entity Framework application. The Entity Framework uses storage model metadata to translate queries against the conceptual model to store-specific commands. For more information on SSDL visit the link:
SSDL Specification :Store schema definition language (SSDL) is an XML-based language that describes the storage model of an Entity Framework application.
In an Entity Framework application, storage model metadata is loaded from a .ssdl file (written in SSDL) into an instance of the System.Data.Metadata.Edm.StoreItemCollection and is accessible by using methods in the System.Data.Metadata.Edm.MetadataWorkspace class. The Entity Framework uses storage model metadata to translate queries against the conceptual model to store-specific commands.

MSL :It is an XML-based language that describes the mapping between the conceptual model and storage model of an Entity Framework application.
MSL Specification :Mapping specification language (MSL) is an XML-based language that describes the mapping between the conceptual model and storage model of an Entity Framework application.
In an Entity Framework application, mapping metadata is loaded from an .msl file (written in MSL) at build time. The Entity Framework uses mapping metadata at runtime to translate queries against the conceptual model to store-specific commands.




Thanks,
Paras Sanghani

No comments:

Post a Comment