The best way to examine the two products is to look at some of the differences in the functionality that they support.
LINQ to SQL -
- The goal in the design of LTS is clearly Rapid Development, where your database for the most part is Mirrored In Your Domain Model (that is, Table per Class), and foreign keys are exposed as strongly typed relationships.
- According to MSDN, LTS is “designed to provide Strongly Typed LINQ Access for rapidly developed applications across the Microsoft SQL Server family of databases.
- LTS is best suited for Rapid Application Development specifically against a Microsoft SQL Server database. This message is both espoused by Microsoft.
- LTS generates a very simple ORM, as compared to other ORM solutions that provide you with a plethora of properties and options.
- Along with the simple UI, LTS also offers Table per Hierarchy inheritance, the most straightforward form of inheritance in ORM.
- LTS is geared specifically at direct 1:1 mapping of .NET classes to SQL Server database tables.This is animportant point about LTS that supports the assertion that LTS is ideal for simple applications.
- LTS really supports only a direct mapping of your database schema to your classes and is limited in some of its functionality.
These all excludes LTS from many enterprise environments because of its limited out-of-the-box support for complex scenarios.
Entity Framework -
Alternatively, MSDN classifies EF as “designed to provide Strongly Typed LINQ Access for applications requiring a More Flexible Object-Relational Mapping, across Microsoft SQL Server and third-party databases.”
- Additionally, EF is classified as the Enterprise Solution because it separates its metadata into Well-Defined Architectural Layers (Conceptual, Mapping, Schema). EF uses a Complex Mapping Algorithm to separate the metadata into layers (that is, Conceptual, Storage, Mapping), which enables you to model your domain based on entities vs. database tables. For example, in EF you can map a single entity to one or more tables or views, or you can map multiple entities to the same table or view.
- These layers are well suited for a large enterprise because they provide you with Loose Coupling And Fine-Grained Control over the conceptual and physical models.
- The important aspect that demonstrates EF’s ability to be an enterprise solution is its support for inheritance. Unlike LTS, which supports simple inheritance only in the form of Table per Hierarchy, EF supports all the core ORM inheritance patterns. These patterns include Table per Hierarchy, Table per Class, and Table per Concrete Class.
- Another reason why EF has rock star status is because of its support for Complex Composite Types and Many-To-Many Relationships.
- Additionally, where EF has LINQ to Entities, which is similar in design to LTS, EF also has Entity Sql and a Strong Provider Model.
- Additionally, EF is approaching Provider Independence and has overall momentum in the community, things that LTS is missing.
- In addition, whereas LTS is designed only as LINQ to SQL, EF presents many other constructs (for example, ESQL and provider independence) as well as LINQ to Entities.
Thanks & Regards,
Arun Manglick Senior Tech Lead