Monday 22 September 2014

An Introduction to Entity Framework

What is Entity Framework :

 

Entity Framework (EF) is an object-relational mapper (ORM) that enables .NET developers to work with relational data using domain-specific objects. It basically generates business objects and entities according to the database tables and allow us to perferm basic CRUD (Create, Read, Update, Delete) operations,maintaining relationship (1 to 1, 1 to many, many to many) and also provides ability to have inheritance relationships between entities. 


What is ORM :

ORM is a tool for storing data from domain objects to relational database like MS SQL Server.ORM includes three main parts: 

                1.Domain class objects
                2.Relational database objects
                3.Mapping information on how domain objects map to relational database objects
                  (tables, views & stored procedures).

ORM allows us to keep our database design separate from our domain class design.It also automates standard CRUD operation (Create, Read, Update & Delete) so that the developer doesn't need to write it manually.



Why to use EF  OR What is the Advantage of using it :

  • It increases the productivity by reducing the development time. It eliminates the need of writing the data-access code as the framework itself provides the core data access capabilities.So developers can only concentrate on application logic.
  • Decreases the maintainability as we have the fewer lines of code to fetch data from database,so fewer lines of code we have to maintain. This is very effective for big projects.
  • Applications are free from hard-coded dependencies on a particular data engine or storage schema. Its is a conceptual model which is independent of physical model. We can easily run our application using different RDBMSs (MySql, MS SQL,SQLite ,Oracle etc.), only by changing configurations.

Is it an alternative to ADO.NET :

 

The answer would be "yes and no". Yes because the developer will not be writing ADO.NET methods and classes for performing data operations and No because this model is actually written on top of ADO.NET, which means this framework still uses ADO.NET. So EF can neither replaces nor succeeds ADO.NET.


Important versions history of EntityFramework:


EntityFramework Version                             Introduced Features
EF 3.5 Basic O/RM support with Database First approach.
EF 4.0 POCO Support, Lazy loading, testability improvements, customizable code generation and the Model First approach.
EF 4.1 First to available of NuGet package, Simplified DBContext API over ObjectContext, Code First workflow.
EF 4.1.1 In addition to bug fixes for EF 4.1 this patch release introduced some components to make it easier for design time tooling to work with a Code First model.
EF 4.2 This release includes bug fixes to the EF 4.1.1 release.
EF 4.3 Code First Migrations feature that allows a database created by Code First to be incrementally changed as your Code First model evolves.
EF 4.3.1 patch released with bug fixing of EF 4.3.
EF 5.0 Announced EF as Open Source. Introduced Enum support, table-valued functions, spatial data types, multiple-diagrams per model, coloring of shapes on the design surface and batch import of stored procedures, EF Power Tools and various performance improvements.
EF 6.0 It includes many new features related to Code First & EF designer like asynchronous query & save, connection Resiliency, dependency resolution,Improved transaction support etc.
EF 6.0.1 The 6.0.1 patch release is limited to fixing issues that were introduced in the EF6 release (regressions in performance/behavior since EF5).
EF 6.0.2 patch released with bug fixing some performance and functional issues of EF 6.
EF 6.1 This minor release adds few new features to EF6.It includes Tooling consolidation,handling of transaction commit failure and Index attribute

Hope this will help you.. :)

No comments:

Post a Comment