LINQ To SQL Vs Entity Framework

Document Sample
LINQ To SQL Vs Entity Framework Powered By Docstoc
					                                  Articles from Jinal Desai
LINQ To SQL Vs Entity Framework
2012-05-19 17:05:50 Jinal Desai

Entity Framework is ORM(Object Relational Mapping) introduced by Microsoft. It proves very useful for
new developers for it’s simplicity to query against conceptual schema and also has rich feature set. Many
time the question has been asked in the interview to explain differences between Entity Framework and
LINQ To SQL to the developers who has work experience in Entity Framework. I have made table of
differences between these two technologies.

  Parameter                  LINQ To SQL                                    Entity Framework
                    LINQ To SQL supports only
                    Microsoft SQL Server 2000 With Entity Framework you can plug any DB Server i.e.
DB Server           and later version and even IBM DB2, Sybase SqlAnyWhere, Oracle, SQL Azure, and
                    SQL Server 2000 has some lot more.
                    limitations.
                    In LINQ To SQL inheritance           In Entity Framework inheritance is simple to apply. It
                    is difficult to apply. It supports   supports Table Per Class Hierarchy(TPH) and Table Per
Inheritance
                    Table Per Class                      Type(TPT). It also provides limited support of Table Per
                    Hierarchy(TPH).                      Concrete Class(TPC).
Complex
Type(Non
scalar property
                LINQ To SQL does not
of an entity
                support the creation of                  Entity Framework support the creation of complex types.
type that does
                complex types.
not have a key
property)
Support
                    LINQ To SQL is easier to             Entity Framework is more complex compared to LINQ To
Complexity
                    use.                                 SQL.
                                                         Entity Framework enable decoupling DB
                    LINQ To SQL provides one-
                                                         Server(Database Schema) and Entity Representaion in
Model               to-one mapping of tables to
                                                         terms of Model(Conceptual Schema). You can map one
                    classes.
                                                         table to multiple entities or multiple table to one entity.
                    LINQ To SQL is simple to
                    learn and implement for       Entity Framework has more features which will take time
Development
                    Rapid Application             to learn and implement, but it will work in complex
Time
                    Development, but it will not  applications.
                    work in complex applications.
             In LINQ To SQL each table is
             mapped to single class. Join
             table must be represented as
Mapping Type a class. Also, complex types In Entity Framework a class can map to multiple tables.
             cannot be easily represented
             without creating separate
             table.
                    It uses Database Markup
                    Language(DBML) file that             Entity Framework uses four files EDMX, CSDL, SSDL
File Type
                    contains XML mappings of             and MSL. The later three are generated at runtime.
                    entities to tables.
                                                         With the Entity Framework, we can query database using
                                                         LINQ To Entities through the ObjectContext object and
                    LINQ To SQL has
                                                         ESQL(provides SQL like query language). In addition,
Query               DataContext object through
                                                         Entity Framework has ObjectQuery class(used with
                                                 Entity Framework has ObjectQuery class(used with
Capability        which we can query the
                                                 Object Services for dynamically constructing queries at
                  database.
                                                 runtime) and EntityClient provider(runs query against
                                                 conceptual model).
                  LINQ To SQL is slow for the
                                                  Entity Framework is also slow for the first run, but after
                  first time run. After first run
Performance                                       first run provides slightly better performance compared to
                  provides acceptable
                                                  LINQ To SQL.
                  performance.
            Microsoft intended to
            obsolete LINQ To SQL after
Future      the Entity Framework
                                                 Entity Framework has future enhacements.
Enhancement releases. So it will not
            receive any future
            enhancements.
Generate      It has no capability to
                                                 Entity Framework supports generation of database from
Database from generate database from
                                                 Model.
Model         Model.


             Blog this!

             Bookmark on Delicious

             Digg this post

             Recommend on Facebook

             Share on FriendFeed

             Share on Linkedin

             Share on Orkut

             share via Reddit

             Share with Stumblers

             Share on technorati

             Tweet about it

             Subscribe to the comments on this post

				
DOCUMENT INFO
Description: Entity Framework is ORM(Object Relational Mapping) introduced by Microsoft. It proves very useful for new developers for it’s simplicity to query against conceptual schema and also has rich feature set. Many time the question has been asked in the interview to explain differences between Entity Framework and LINQ To SQL to the developers who has work experience in Entity Framework. I have made table of differences between these two technologies.