Skip to main content

Introduction to ADO.Net Entity Framework 4

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.

EF Layout

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

Popular posts from this blog

Health Framework - Apple vs Android

In the past few years we have seen mobile and its apps rise and shine transforming many industries in its wake. However, the growth in health and fitness category has been less spectacular at 49% compared to overall mobile app industry which grew at 115% in the year 2013 (source Flurry Analytics). A few years ago Microsoft and Google attempted to make inroads into the health and fitness sector by bringing web based products to store and maintain health and fitness information like MS HealthVault and Google Health with not so spectacular results. Next came innovations by Fitbit in the wearables sector for activity tracking, in 2011 and 2012 they introduced first wireless activity trackers to sync using Bluetooth. This was followed by the entry of Jawbone into health sector with its announcements of Up wristband and accompanying app. These have had better success resulting in many startups joining the wearables product bandwagon.  Late to the stage almos...

Notes on Castle MonoRail

  Sometime back I was doing a small POC on Castle MonoRail. So here are my quick notes on this. MonoRail is an MVC Framework from Castle inspired by ActionPack. MonoRail enforces separation of concerns with Controller handling application flow, models representing data and View taking care of the presentation logic. To work with MonoRail you need Castle Assemblies. It also utilizes nHibernate You can use Castle MonoRail Project Wizard or create the project manually. Project structure – Content Css Images Controllers HomeController.cs Models Views Home \ index.vm Layouts \ Default.vm ...

Quick notes on Git

  I have been away from writing anything for a long time and instead have been fooling around with other stuffs like just plain reading, growing mustache, trying to learn swimming, trying to learn to play acoustic guitar and trying my hands at photography. To be honest I have not given up on them yet but neither have I been able to hang on to them in a disciplined manner. So here I am back to my writing after a long gap. This time its going to be quick notes on Git . Git is a file repository. As opposed to other repositories like SVN Git thinks of its data more like a snapshot of a mini filesystem. All operations in Git are local. (Entire history of the project is stored locally in your working directory) Browsing project history. Viewing all changes to a file. Git uses Checksum to track repository items Everything in Git is check-summed It uses SHA-1 hash for generating check sum values All a...