6

I was reading this article about ADO.NET Entity Framework and found it to be very interesting though in the first shot I could not decipher many things. I am reading the article again in order to fathom the real logic behind this.

a) A question cropped in my mind is why we need an ORM framework (in general)?

b) And among other ORM frameworks present for .NET like Spring.NET, Linq to Sql , NHibernate etc. why will we prefer ADO.NET Entity Framework?

Michael Maddox
  • 12,331
  • 5
  • 38
  • 40
priyanka.bangalore
  • 1,471
  • 7
  • 20
  • 32
  • 1
    Entity Framework is the primary ORM currently being pushed forward by Microsoft. If you want to get your ORM from Microsoft, that is a reason to choose it. Other ORMs offer different features and there are many other questions on StackOverflow about comparing .NET ORMs (http://stackoverflow.com/questions/1377236/nhibernate-entity-framework-active-records-or-linq2sql/). – Michael Maddox Feb 20 '10 at 10:57

5 Answers5

10

b. Subjective. I might not be able to offer a good opinion, as I have not used EF.

Community
  • 1
  • 1
virtualmic
  • 3,173
  • 6
  • 26
  • 34
5

There are several advantages. Important among them are :

  1. Provides dedicated functionality for CRUD operation (Create, Read, Update, Delete). Easy to implement CRUD operations.

  2. If you want to replace the data store, it is very easy to replace without modifying the data access logic since all data access logic are present in higher level.

  3. Easy to manage one to one, one to many and many to many relationship between tables.

  4. Conceptual model can be represented in a better way.

  5. Developer can reduce the code in classes and sub-classes for data access.

3

EF is to create logical objects from the relational SQL tables. Generally, you want to reasonably match your physical tables with your objects, but sometimes it doesn't work that way. It promotes Persistence Ignorance.

Zachary Scott
  • 20,968
  • 35
  • 123
  • 205
2

Here's some of my thoughts:

a) ORM's exist to simplify and reduce the workload on the developer. In many well-designed relational models, the database can be accessed via code that is highly repetitive (just change a table name, column names, but the behavior is very similar). An ORM generates code that the developer can use right away, and tweak as necessary. The developer does not need to write SQL - that is the job of the ORM now. It also refreshes the generated code by automatically adjusting to database schema changes.

b) I don't know. It really depends on your requirements and dependencies. How involved do you want your ORM to be? How important is performance? How developer-friendly do you want the code to be? Entity Framework tends to generate a more comprehensive class library as the data-access layer, while giving you visual tools to tweak the generated code. Linq to SQL tends to be easier to sprinkle throughout different methods. That's just one example.

Jeff Meatball Yang
  • 37,839
  • 27
  • 91
  • 125
0

a) an ORM framework abstracts away the boilerplate data layer access code: you simply deal with objects in code.

b) Depends on your circumstances and requirements.

Mitch Wheat
  • 295,962
  • 43
  • 465
  • 541