Entity Framework - Overview



What is Entity Framework?

Entity Framework was first released in 2008, Microsoft's primary means of interacting between .NET applications and relational databases. Entity Framework is an Object Relational Mapper (ORM) which is a type of tool that simplifies mapping between objects in your software to the tables and columns of a relational database.

  • Entity Framework (EF) is an open source ORM framework for ADO.NET which is a part of .NET Framework.

  • An ORM takes care of creating database connections and executing commands, as well as taking query results and automatically materializing those results as your application objects.

  • An ORM also helps to keep track of changes to those objects, and when instructed, it will also persist those changes back to the database for you.

Why Entity Framework?

Entity Framework is an ORM and ORMs are aimed to increase the developer’s productivity by reducing the redundant task of persisting the data used in the applications.

  • Entity Framework can generate the necessary database commands for reading or writing data in the database and execute them for you.

  • If you're querying, you can express your queries against your domain objects using LINQ to entities.

  • Entity Framework will execute the relevant query in the database and then materialize results into instances of your domain objects for you to work within your app.

There are other ORMs in the marketplace such as NHibernate and LLBLGen Pro. Most ORMs typically map domain types directly to the database schema.

Typical ORM

Entity Framework has a more granular mapping layer so you can customize mappings, for example, by mapping the single entity to multiple database tables or even multiple entities to a single table.

EF Runtime Metadata
  • Entity Framework is Microsoft's recommended data access technology for new applications.

  • ADO.NET seems to refer directly to the technology for data sets and data tables.

  • Entity Framework is where all of the forward moving investment is being made, which has been the case for a number of years already.

  • Microsoft recommends that you use Entity Framework over ADO.NET or LINQ to SQL for all new development.

Conceptual Model

For developers who are used to database focused development, the biggest shift with Entity Framework is that it lets you focus on your business domain. What it is that you want your application to do without being limited by what the database is able to do?

  • With Entity Framework, the focal point is referred to as a conceptual model. It's a model of the objects in your application, not a model of the database you use to persist your application data.

  • Your conceptual model may happen to align with your database schema or it may be quite different.

  • You can use a Visual Designer to define your conceptual model, which can then generate the classes you will ultimately use in your application.

  • You can just define your classes and use a feature of Entity Framework called Code First. And then Entity Framework will comprehend the conceptual model.

Conceptual Model

Either way, Entity Framework works out how to move from your conceptual model to your database. So, you can query against your conceptual model objects and work directly with them.

Features

Following are the basic features of Entity Framework. This list is created based on the most notable features and also from frequently asked questions about Entity Framework.

  • Entity Framework is a Microsoft tool.
  • Entity Framework is being developed as an Open Source product.
  • Entity Framework is no longer tied or dependent to the .NET release cycle.
  • Works with any relational database with valid Entity Framework provider.
  • SQL command generation from LINQ to Entities.
  • Entity Framework will create parameterized queries.
  • Tracks changes to in-memory objects.
  • Allows to insert, update and delete command generation.
  • Works with a visual model or with your own classes.
  • Entity Framework has stored Procedure Support.
Advertisements