Ragioni per preferire Entity Framework a Linq to Sql con SQL Server

Con risposta Ragioni per preferire Entity Framework a Linq to Sql con SQL Server

  • martedì 8 maggio 2012 00:16
     
     

    Salve!

    Devo realizzare un'applicazione intranet WPF che prende i dati da un Server SQL (framework 4.0)

    Da quanto ho potuto capire se i dati stanno tutti su SQL Server la scelta preferenziale dell'infrastruttura ricade su Linq to SQL, mentre Entity Framework è più indicato quando i dati provengono da fonti eterogenee.

    Però ho sentito anche voci discordanti. Sono ancora in tempo per scegliere. Voi cosa mi consigliate?

    Pileggi

Tutte le risposte

  • martedì 8 maggio 2012 00:35
    Postatore
     
     Con risposta
    Primo motivo: LINQ To SQL è stato dismesso, non sono più state sviluppate nuove versioni poco dopo il rilascio di Entity Framework 2.0.

    Questi sono altri motivi per preferire Entity Framework:

    1. L2S is tightly coupled - object property to specific field of database or more correctly object mapping to a specific database schema
    2. L2S will only work with SQL Server
    3. EF allows mapping a single class to multiple tables
    4. EF will handle M-M relationships
    5. EF will have ability to target any ADO.NET data provider
    6. 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
    7. 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

    Quindi ricapitolando:
    1. LINQ To SQL è incompleto
    2. supporta solo il mapping 1:1, 1 entity - 1 tabella
    3. non è un ORM, al contrario di Entity Framework


    Matteo Migliore

    Bloghttp://blogs.ugidotnet.org/matteomigliore
    Twitterhttp://twitter.com/matteomigliore
    CodePlex

    • Contrassegnato come risposta pileggi martedì 8 maggio 2012 08:26
    •  
  • martedì 8 maggio 2012 07:02
     
     
    Ci sono casi dove LinqToSQL rimane l'unica scelta, come ad esempio con SQL Compact per Windows Phone 7. In tutti gli altri casi, ovviamente vale quanto già detto da Matteo Migliore.
  • martedì 8 maggio 2012 08:27
     
     

    ok mi sembra sufficiente... cambio!

    Pileggi