What is Entity Framework ? What are POCO entities ?

What is Entity Framework?

Entity Framework is Microsoft’s recommended data access technology for new applications.

The Microsoft ADO.NET Entity Framework is an Object/Relational Mapping (ORM) framework that enables .NET developers to work with relational data using domain-specific objects. It eliminates the need for most of the data-access code that developers usually need to write.

Using the Entity Framework, developers issue queries using LINQ, then retrieve and manipulate data as strongly typed objects.

The Entity Framework’s ORM implementation provides services like change tracking, identity resolution, lazy loading, and query translation so that developers can focus on their application-specific business logic rather than the data access fundamentals.
EF maps to the database tables using a model. This model is responsible for mapping the application’s entities and their relationships to the data held in the physical database. It’s a combination of three layers, and is stored as an Entity Data Model (.edmx) file. .edmxis an XML based file that consists of these 3 layers.

Storage Layer: this is defined with Store Schema Definition Language (SSDL). Table structures and their relationships are defined here.

Conceptual Layer: this is defined with Conceptual Schema Definition Language (CSDL). Business entities and their relationships are described in the conceptual schema.

Mapping Layer : This is defined with Mapping Specification Language (MSL). It maps the conceptual schema to the storage schema. The mapping schema describes how the business entities map to the database schema, and how database tables map to the entities in the model.

What are the different versions of Entity Framework?

The first version of Entity Framework (EFv1) was included with .NET Framework 3.5 Service Pack 1 and Visual Studio 2008 Service Pack 1, released on 11 August 2008. This version has been widely criticized, even attracting a ‘vote of no confidence’ signed by approximately one thousand developers.

The second version of Entity Framework, named Entity Framework 4.0 (EFv4), was released as part of .NET 4.0 on 12 April 2010 and has addressed many of the criticisms made of version 1.

A third version of Entity Framework, version 4.1, was released on April 12, 2011, with Code First support.

A refresh of version 4.1 named Entity Framework 4.1 Update 1, was released on July 25, 2011. It includes bug fixes and new supported types.

The latest version is 4.3.1, which was released on February 29, 2012. There are a few updates, like support for migration.

Features of Entity Framework

Provides integrated Visual Studio tools to visually create entity models and to auto-generate models from an existing database. New databases can be deployed from a model, which can also be hand-edited for full control.

Provides a Code First experience to create entity models using code. Code First can map to an existing database or generate a database from the model.

Integrates well into all the .NET application programming models including ASP.NET, Windows Presentation Foundation (WPF), Windows Communication Foundation (WCF), and WCF Data Services (formerly ADO.NET Data Services)

Works with a variety of database servers (including Microsoft SQL Server, Oracle, and DB2)

Benefits / Advantages of using Entity Framework

Reduced development time: the framework provides the core data access capabilities so developers can concentrate on application logic.

Developers can work in terms of a more application-centric object model, including types with inheritance, complex members, and relationships. In .NET Framework 4, the Entity Framework also supports Persistence Ignorance through Plain Old CLR Objects (POCO) entities.

Applications are freed from hard-coded dependencies on a particular data engine or storage schema by supporting a conceptual model that is independent of the physical/storage model.

Mappings between the object model and the storage-specific schema can change without changing the application code.

Language-Integrated Query support (called LINQ to Entities) provides IntelliSense and compile-time syntax validation for writing queries against a conceptual model.

Developer Workflows — (Code First/Model First/Database First)

Entity Framework has three developer workflows to help you access data in your application:

Code First — As the name suggests this approach is all about code. You write the classes that make up your domain model. A set of conventions map these classes to a database schema but you can provide additional mapping using code. Code First can map to an existing database or generate a database schema for you based on your model and mapping. If you are targeting an existing database the EF Power Tools can help you get started by generating basic classes and mapping for you.

Model First — You build your model using ‘boxes and lines’ in the Entity Model Designer. Once you model is created the designer will generate a database schema for your model. The classes that make up your domain model are generated for you.

Database First — If you have an existing database this approach allows you to reverse engineer a ‘boxes and lines’ model in the designer. You can then tweak the shape of the model and how it maps to your existing database schema. The classes that make up your domain model are generated for you.

What are Poco Entities ?
POCO stands for Plain Old CLR Object and refers to an object that does not have any persistence concerns and is not aware of persistence framework. Modern development approaches such as DDD (Domain-Driven Design) and TDD (Test-Driven Development) prefer clear separation of concerns which implies persistence ignorance.
The POCO Template can be used to generate persistence ignorant entity types from an Entity Data Model.

What do you mean by Ninject ?
Ninject is a lightweight dependency injection framework for .NET applications. It helps you split your application into a collection of loosely-coupled, highly-cohesive pieces, and then glue them back together in a flexible manner. By using Ninject to support your software’s architecture, your code will become easier to write, reuse, test, and modify.

Related Video