Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Basically, I have a very good knowledge of plain old SQL coming from Classic ASP programming.

Over the past couple of months, I have been learning C# and today was my first full day at MVC 3 (Razor) which I am loving!

I need to get back in to Databases and I know that writing SqlCommand everywhere is obviously outdated (although it is nice I can still do it!).

I used to go to a great usergroup as an IT Pro and the developer stuff went completely over my head, however I do remember a few things which kept coming up such as LINQ... However, that was some time ago and now the same people on Twitter are saying how out dated it is.

I have tried to do research on both and I am clueless as to what direction I should go in, or when to use one over another (if learning both is a good thing).

I am more so confused as I thought EF was a part of the .Net Framework, however, reading through the quick start guide, I had to download a component using Nuget.

... Basically I am out of my depth here and just need some honest advice of where to go!

share|improve this question

closed as off-topic by gnat, GlenH7, MichaelT, Doc Brown, Bart van Ingen Schenau Dec 26 '13 at 10:55

This question appears to be off-topic. The users who voted to close gave these specific reasons:

  • "Questions seeking career or education advice are off topic on Programmers. They are only meaningful to the asker and do not generate lasting value for the broader programming community. Furthermore, in most cases, any answer is going to be a subjective opinion that may not take into account all the nuances of a (your) particular circumstance." – gnat, Doc Brown, Bart van Ingen Schenau
  • "Questions about what language, technology, or project one should take up next are off topic on Programmers, as they can only attract subjective opinions for answers. There are too many individual factors behind the question to create answers that will have lasting value. You may be able to get help in The Whiteboard, our chat room." – GlenH7, MichaelT
If this question can be reworded to fit the rules in the help center, please edit the question.

add comment

4 Answers 4

up vote 6 down vote accepted

You should absolutely learn Linq the language. In my project we use it only about 50% of the time to get data in or out of a database. You can just as easily use it against other sources such as XML and objects, both of which we do lots more of.

I assume you're meaning Linq To Sql. It and EF provide very similar functionality in working with databases. We currently use both in various projects. I have a strong background in SQL so I look at both and go, "Meh." I'm not completely sold on either. I don't dislike them, they're fine. But ultimately it's just getting data in or out of a database which can be done in a ton of different ways.

One thing to keep in mind is that both L2S and EF utilize code generation to create their entities. Through T4 you have the ability to do your own code generation, and have it generate your stored procs and data access layer, if you like procs better.

Where I do like L2S and EF is when you need a quick query that joins tables, that creating a stored proc might be overkill for. You can also use it to populate your POCO objects directly in the queries, which is very nice.

Personally, if it's just about getting data in or out of a database use what you know, but do learn Linq for use against other sources of data.

share|improve this answer
    
The new EF 4.1 feature set does not necessarily use code generation. Read about the code-first features weblogs.asp.net/scottgu/archive/2010/12/08/… –  Mike Brown Mar 13 '11 at 0:11
add comment

Hopefully this might provide some clarity.

  1. The nuget package that you downloaded was for a preview of Entity Framework 4.1. Like MVC, EF sometimes has what is called Out of Band deliveries (additional functionality provided separate from the primary .NET framework).
  2. LINQ is worth learning in general because it is useful outside of data access scenarios (e.g. PLinq for concurrent operations over sets). It can be used with EF or over objects in general.
  3. LINQ2SQL was a stop-gap framework for providing a data-access layer using the new (at the time LINQ syntax. EntityFramework is the primary data access strategy for the .NET platform going forward.
  4. It's worth learning how to use SQLCommands just so that you can understand how they work. Just like it's worth learning GDI so you know how Winforms does its magic.
share|improve this answer
add comment

Learn 'Entity Framework' and don't look back, not even for a second. ORM's are definitely the way things are heading these days.

Oh and google "Linq to SQL is dead" - it's not necessarily dying, but reading about why people think it's dying is worth noting.

And as far as writing plain string sql statements in your code, that's really dead.

share|improve this answer
add comment

In addition to what's already been mentioned: If you have a small to medium site and are just doing basic data retrieval, Linq 2 SQL should suit you just fine. Entity Framework is billed as more of an Enterprise solution. The biggest issue with Linq to SQL in my experience has been that you can't automatically refresh your data model if your database changes (EF supports this)... If you change a table, you typically have to drop that table in your L2S designer and add it back.

See LINQ to SQL vs. ADO.NET Entity Framework for a good comparison of L2S vs EF:

share|improve this answer
    
I would argue that even for small projects EF is alot easier to understand/use. I recently built an ajax based chat with EF and it was a breeze. –  foreyez Mar 13 '11 at 2:29
1  
I actually found L2S easier to learn. I did learn it first, so maybe that has something to do with it. Realistically though for simple data access - the differences are fairly trivial. –  jlnorsworthy Mar 13 '11 at 2:40
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.