The ADO.Net Entity Framework 4 is an ORM (Object Relational Mapping) framework that allows developers to work with relational data as application specific objects, freeing us from the need to write the data access plumbing code. We us LINQ to query data and retrieve and manage data as strongly typed objects. EF also provides us with services like change tracking, lazy loading and query translation. It supports the development of data – oriented software applications.
Features of Entity Framework 4 -
- Works with a variety of databases (SQL Server, Oracle, and DB2)
- Rich mapping engine to map application objects to database schema.
- Integrated Visual Studio tools to visually create models or to auto generate models from an existing database (EDM Generator and EDM Designer).
- Integrates well into any .net applications like asp.net, WPF and WCF.
- Programming model similar to ADO.Net since EF4 is built on top of existing ADO.Net provider model.
- Reduced development time.
- Application centric object model that includes types with inheritance, complex members and relationships.
- Decoupling application from physical / storage model.
- LINQ based querying brings in IntelliSense and compile time syntax validation for writing queries against a conceptual model.
- Supports mapping application objects to stored procedures in database.
EF4 layout -
- Application uses ORM interfaces of Entity Framework.
- Entity Framework uses EDM (Entity Data Model) to describe object relational mappings.
- The conceptual model, the storage model and the mappings between the two are expressed in xml schemas -
- Conceptual Schema is defined in files with .csdl extensions (Conceptual Schema Definition Language).
- Storage model or logical model is defined in files with .ssdl extensions (Store Schema Definition language).
- Mappings between the storage and conceptual models is defined in files with .msl extension (Mapping specification language).
- Entity Framework internally utilizes EntityClient data provider to manage connections, translate entity queries into data source specific queries. This EntityClient data provider extends ADO.Net provider model by accessing data in terms of conceptual entities and relationships.
- Entity Framework interacts with ADO.Net Provider for accessing data.
- ADO.Net provides queries or updates data in physical data store.
Why embrace Entity Framework -
Most of the time development teams skip creating a conceptual model and straight away start off with creation of tables, columns, key and relationships in a relational databases. Entity Framework encourages developers to take a look at the application objects / model and gives freedom to design it well by making it a main stream approach to work with data and relationships by querying these application objects.
Entity Framework 4 provides various ways to query a conceptual model as listed below -
- LINQ to Entities – This allows developers to write queries in C# or VB which get converted to command tree queries and are executed against the Entity Framework and return objects that can be used by both Entity Framework and LINQ.
- Entity SQL – This is a SQL like language that enables you to query conceptual models in the Entity Framework. It makes use of EntityClient Provider to execute Entity SQL against an Entity Framework. It provides objects like EntityCommand and EntityDataReader and is included in the System.Data.EntityClient namespace.
- Query builder methods – Query builder methods encapsulated in ObjectQuery class can be used sequentially to construct query commands that are equivalent to Entity SQL.
This is just an introductory post on Entity Framework 4 I will be doing a deep dive posts sometime later.
Comments