6

I know the benefit of the LINQ and I know use of it in .Net Application. I fill same thing there are providing as a Entity Framework.

So What's Major Difference between LINQ and Entity Framework?

Mrugesh
  • 461
  • 4
  • 16

4 Answers4

12

LINQ could be applied to any data source: in-memory objects, XML, SQL, ...

Entity Framework could use LINQ to perform queries against a relational database.

LINQ to SQL is the predecessor of Entity Framework and is obsolete now.

Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
  • As I'm using EF for enterprise solution, that get big and bigger model everyday so we have performance problem specially in the first initialization EF (or warming up it), I read this http://weblogs.asp.net/fbouma/fetch-performance-of-various-net-orm-data-access-frameworks and now I'm hesitant if I must to change ORM or not? maybe using dapper(and I know it hasn't change tracking) or LLBLGenPro can be help! We are working on enterprise level solutions and I hope to know what you think about. Thanks so much. – QMaster Dec 25 '14 at 10:52
7

Comparing EF and LINQ is incorrect. Both are different things and they often work together to give better developer experience (and productivity benefit).

LINQ is querying syntax/model that can be applied to any data source. EF provides one such data source.

VinayC
  • 47,395
  • 5
  • 59
  • 72
  • Can you provide any tutorial link or artical link which can show me EF and LINQ using together? – Mrugesh Jan 24 '13 at 07:45
  • @Mrugesh, I believe that almost every EF code sample on MSDN would be showing use of LINQ along with e.g. see this: http://msdn.microsoft.com/en-us/data/jj205424 where `query` part is LINQ. I hope that your are not confusing `LINQ` with `LINQ to SQL` - the later is ORM library (similar to EF) meant for SQL Server database (while EF targets any RDBMS). – VinayC Jan 24 '13 at 09:27
2

They are somewhat similar, and can be used in a very similar way, code-wise, but they have some important differences. Note that "LINQ" is not the same thing as "LINQ to SQL"; the EF also uses LINQ. Some notable differences are:

  • LINQ to SQL is largely SQL Server only, not so much by design as by implementation. The EF is designed to support, and does support, multiple DBs, if you have a compatible ADO.NET provider.
  • Out of the box, LINQ to SQL has a very poor story for DB metadata changes. You have to regenerate parts of your model from scratch, and you lose customizations.
  • The EF supports model features like many-to-many relationships and inheritance. LINQ to SQL does not directly support these.
  • In .NET 3.5, LINQ to SQL had much better support for SQL-Server-specific functionality than the EF. This is mostly not true in .NET 4; they're fairly similar in that respect.
  • The EF lets you choose Model First, DB First, or Code First modeling. LINQ to SQL, out of the box, really only supports DB First.

SOURCE : Here

Community
  • 1
  • 1
Parimal Raj
  • 20,189
  • 9
  • 73
  • 110
1

I totally agree with VinayC. You cannot really compare.

With Entity Framework, you will be able to have a whole representation of your database in your program. It will help you create classes corresponding to the database elements, connected together like they are in the database. You can after interact with elements of theses classes directly, and like this impact the database. You will have some representation of these classes diagram in visual studio. It's basically often simpler than working directly with the database elements, even if setting it up requires some effort.

The use of Linq is to perform queries on the data sources.