The following sections cover the benefits of using an ORM solution, although please note that some of these advantages are not EF-specific—excellent (and more mature) alternatives do exist. Probably the best-known and one of the most mature ORM solutions in the .NET world is NHibernate. You can, however, view an extensive list at http://en.wikipedia.org/wiki/List_of_object-relational_mapping_software.
Data is generally held in a relational manner that is optimized for storage and quick retrieval (well, in most cases it should be). However, this format tends to not map that easily to how we want to work with the entities involved. ORM solutions can provide a conceptual mapping that allows you to organize your entities and their properties in a manner that is different than how they are physically stored.
For example, I worked on an application for a hospital that stored data about patients in two tables: Person and Patient. These tables had a one-to-one relationship. Person held demographic details and Patient held clinical-specific information. Whether this is the best database design is not important, but you can probably see that when you want to work with a "patient," it is tedious to have to work with two separate objects. EF allows you to create an object that is spread across two tables, allowing you to write more intuitive code, such as the following:
Patient.Firstname Patient.BloodType
A great advantage of using an ORM solution is that it provides basic CRUD (created, read, update, delete) functionality, saving you from having to write this part. As code is automatically generated, the potential for errors is also reduced. Using an ORM can also make it easier to adhere to naming conventions, as classes and methods are automatically generated.
It is worth noting that by utilizing an ORM framework for data access, you are introducing additional overhead to data access, and that for high performance applications, you may be better off working with the database directly. Generally, however, the performance implications will probably be pretty minimal and outweighed by the other advantages an ORM solution can bring.
EF provides support for a number of different databases in addition to SQL Server, such as Oracle, MySQL, SQLAnywhere, Synergex's Synergy (added recently), and a few more.
EF contains its own query language and mechanisms that provide you with a consistent query mechanism that can be used across many different data sources. EF doesn't care whether your database uses T-SQL or PL/SQL—querying is the same.
EF has excellent design-time support that developers will learn quickly. Yes, it was a bit ropey in the original version, but this is much improved in VS2010. I don't think the majority of ORM solutions provide this level of GUI functionality, so this is definitely one of EF's strengths.
L2E allows you to construct some very complex queries using the .NET Framework that would not be possible with standard SQL (we will look at L2E shortly).
EF has a number of features (particularly in the latest release), such as support for POCOs (plain-old CLR objects) (e.g., .NET classes!) and self-tracking entity templates, that make it a great solution for the development of n-tier applications.
18.217.222.205