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

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 ...

Workflow Foundation 4 - Part 3 - Data storage and management

This is my third post on WF4. First one was an introductory post on WF4 and in second one we focused on executing workflows. In the this post I am going to focus on the topic of data storage and management. Every business process or flow depends on data. When you think of data there are three elements to it as listed below - Variables - for storing data Arguments - for passing data Expressions - for manipulating data. Let us first look at the variables. Variables are storage locations for data. Variables are declared before using them just like in any other languages like C# or VB.Net. Variables are defined with a specific scope. When you create a variable in an activity the scope of the variable becomes that activity's scope. Variables can also have access modifiers like None, Mapped or ReadOnly. Let us look at an example where we will create two variables and assign a scope to them along with access modifiers. //Declare a sequence activitiy Sequence seqWf = new Sequence(); //de...

Introduction to Workflow Foundation 4 (WF4)

I finally decided to pick-up my blogging once more. Since I have been trying to learn Windows Workflow Foundation 4 (WF4) I thought I might as well start off with this topic. WF4 is a development framework that enables you to create a workflow and embed it in a .Net application. It is neither an executable application nor a language. It provides a set of tools for declaring a workflow, activities to create your logic and to define control flow and a runtime for executing the resulting application definition. It also provides services for persistence of state, tracking and bookmarking. You can create your workflow directly in code, in mark-up or in a combination of both. Workflow provide us with two major advantages - Creating unified application logic. Making application logic scalable. Workflow Authoring styles - Sequential Workflow executes a set of contained activities in a sequential manner. Workflow Foundation was introduced in the .Net 3.0 and updated in 3.5. In .net 4 it has bee...