1

I'm trying to query an existing SQL Server database with LINQ on a .NET project. I've been successful to do so by using LINQ to SQL .dbml files, but then I read somewhere I can't remember that this approach is deprecated, then I started investigating the other Data File Types ADO.NET Entity Model (.edmx), DataSet (.xsd), EF DbContext Generator...

I'm a bit consufed about when it is appropriate to use the different the Data file types (the several types of files available in VS), and which one is the most appropriate to solve my problem. Can anyone shed some light on this matter?

Thank you

David Jiménez Martínez
  • 3,053
  • 5
  • 23
  • 43
  • 2
    "that this approach is deprecated" - LINQ-to-SQL is not being further developed, but it works fine; EF has made a lot of advances lately, though. What you are *basically* asking, though, is "what data access technology should I use?" - whichever one meets your needs, and you are happy with. If you've done it in such a way that you can't swap it out easily later, you've probably done it wrong ;p – Marc Gravell Feb 14 '14 at 08:19
  • 1
    The DataSet is older and more deprecated than Linq2Sql. Scratch that one. – H H Feb 14 '14 at 08:24
  • 1
    Personally I love the code first (entity framework) approach for querying databases. But it all depends on the scope and complexity of your project. Doing the code first approach is only worth it if its non-trivial i think. – Sandman Feb 14 '14 at 08:25
  • 1
    LinqToSQl is more accessbile and Entity Data Model is more complex, but more powerful. It all depends on your requirements - I nearly *always* use LinqToSQl for its ease of use. – Andrew Feb 14 '14 at 08:43

2 Answers2

3

In a recent post on extending NerdDinner, Scott Hanselman talked about this very thing. To quote at the end:

Conclusion

There's lots of choices for Database Access on .NET. You'll run into DataReaders in older or highly tuned code, but there's no reason it can't be hidden in a Repository and still be pleasant to use. LINQ to SQL is nice, lightweight and fast and has dozens of bug fixes in .NET 4, but Entity Framework is the way they are heading going forward. Plus, Entity Framework 4 is way better than EF 3.5, so I'm using it for any "larger than small" projects I'm doing and I'm not having much trouble.

http://www.hanselman.com/blog/ExtendingNerdDinnerExploringDifferentDatabaseOptions.aspx

vmg
  • 9,920
  • 13
  • 61
  • 90
  • For the time being, I'll stick with LINQ to SQL (dbml) as I'm facing the issue to create an association between 2 classes whose associated properties are not keys and edmx seems that doesn't allow me that according the following thread: http://stackoverflow.com/questions/7019052/create-association-on-non-primary-key-fields-with-entity-framework-4-1-fluent-ap Thank you everyone for your answers! – David Jiménez Martínez Feb 16 '14 at 17:02
1

Datesets was an approach used before the arrival of Linq. Linq-to-Sql and Entity Framework are both far superior to datasets, so cross that one out.

Linq-to-SQL (.dbml) is not really deprecated, but it is not being developed further. So you can use it if it satisfied your need, but the framework won't get any new features in the future. It is simpler and more lightweight than EM, so if you are familiar with it and it fits your needs for the project in question, it remains a fine choice.

EM (.edmx) have more features, and is being actively developed.

JacquesB
  • 41,662
  • 13
  • 71
  • 86