QBoard » Artificial Intelligence & ML » AI and ML - R » Entity Framework vs LINQ to SQL

Entity Framework vs LINQ to SQL

  • Now that .NET v3.5 SP1 has been released (along with VS2008 SP1), we now have access to the .NET entity framework.
    My question is this. When trying to decide between using the Entity Framework and LINQ to SQL as an ORM, what's the difference?
    The way I understand it, the Entity Framework (when used with LINQ to Entities) is a 'big brother' to LINQ to SQL? If this is the case - what advantages does it have? What can it do that LINQ to SQL can't do on its own?
      September 23, 2021 3:19 PM IST
    0
  • LINQ to SQL only supports 1 to 1 mapping of database tables, views, sprocs and functions available in Microsoft SQL Server. It's a great API to use for quick data access construction to relatively well designed SQL Server databases. LINQ2SQL was first released with C# 3.0 and .Net Framework 3.5.
    LINQ to Entities (ADO.Net Entity Framework) is an ORM (Object Relational Mapper) API which allows for a broad definition of object domain models and their relationships to many different ADO.Net data providers. As such, you can mix and match a number of different database vendors, application servers or protocols to design an aggregated mash-up of objects which are constructed from a variety of tables, sources, services, etc. ADO.Net Framework was released with the .Net Framework 3.5 SP1.
    This is a good introductory article on MSDN: Introducing LINQ to Relational Data
      September 24, 2021 12:25 PM IST
    0
  • I think the quick and dirty answer is that

    • LINQ to SQL is the quick-and-easy way to do it. This means you will get going quicker, and deliver quicker if you are working on something smaller.
    • Entity Framework is the all-out, no-holds-barred way to do it. This means you will take more time up-front, develop slower, and have more flexibility if you are working on something larger.
      September 24, 2021 1:50 PM IST
    0
  • There are a number of obvious differences outlined in that article @lars posted, but short answer is:

    • L2S is tightly coupled - object property to specific field of database or more correctly object mapping to a specific database schema
    • L2S will only work with SQL Server (as far as I know)
    • EF allows mapping a single class to multiple tables
    • EF will handle M-M relationships
    • EF will have ability to target any ADO.NET data provider

    The original premise was L2S is for Rapid Development, and EF for more "enterprisey" n-tier applications, but that is selling L2S a little short.

      September 25, 2021 2:30 PM IST
    0