I am an ASP.NET developer. I want to learn ASP.NET MVC. In fact I am learning it. But Now I am confused at a point. How can I connect my database to my application. Using entity framework or linq or ado.net. I have good knowledge about ado.net. But about entity framework I cant say anything. Now my problem is this whichever ebook or website I see every entity framework is used. So is it essential for me to learn first entity framework before ASP.NET MVC or not?

2 Answers 2


You will have to use LINQ and EF together if you want to do anything more complicated than CRUD with EF. That said, EF makes CRUD dirt simple. Build your models or database, push the changes the other way (update the database or your models respectively), add controllers and views to taste.

If you start getting into more complicated objects than can be stored in a related set of tables (parent, child, grandchild, etc.), you will have to switch over to LINQ. But fear not gentle traveler, LINQ can use the EF objects directly, making a lot of things trivial (e.g., complicated nested, barely related data in structures that would make JSON blush). LINQ also gives you the advantage of being able to use SQL statements directly. AFAIK, you will only be able to use the EF connection while using SQL. I haven't had any need to even use that so far.

EF is getting better and more capable all the time. I don't see it catching up with LINQ, but it might be more than enough for most data access soon.

I would hazard a guess that you can learn EF and MVC at the same time.

I should also mention that you can combine any or all of the technologies you mentioned.

  • 1
    Can you explain how LINQ is ahead of EF, and in what sense?
    – Andy Hunt
    Commented Feb 25, 2014 at 8:32
  • 1
    I am no LINQ or EF expert, but with LINQ, you can query databases, object collections, and XML. That's just with what is already built into LINQ. You can extend LINQ easily by adding lambdas (anonymous functions), standard functions that return a single value, or collection/list/queryable object. You can perform complex evaluations using some of the library objects. As a part of a LINQ query, you can create a collection/list/queryable object of any class you have the ability to instantiate. Commented Feb 25, 2014 at 19:01

You have to see these elements as layers of a cake.

  • ASP .Net WebForms or ASP .Net MVC is the top layer of the cake, namely the user interface layer. This, ideally, should handle the user's browsing and pass anything more complicated than that off to the business logic.
  • The next layer down, the middle of the cake, is the 'business logic', where you'd set rules of your application, or the 'how it all works' coding. Anything more complicated than this, namely reading/writing to the database is passed down again.
  • The bottom layer of the cake, is the data layer; this layer reads and writes data to/from the database, irrespective of whether you're using SQL Server, Access, Oracle, MySQL, whatever.

Learn to cut your code up like this and you'll be in a better position for your career, going forward. (For Dependency Injection, Inversion of Control, Unit Testing, etc etc etc.)

In the case you've mentioned, Entity Framework is known as an Object Relational Mapper, or ORM for short. NHibernate is another example of an ORM. The job of an ORM is to remember that a particular table in your database is 'mapped' to a class object in your code. There are lots of examples on StackOverFlow.com for Entity Framework, but to be honest, I'd buy a book that not directly focused on EF as it sounds like you need an MVC grounding first. Try something like this: ASP .Net 4.

LINQ, however, is something that you can use with coding in general but primarily, you'd use LINQ to query a database, or other collection of objects, as in:

    // The Three Parts of a LINQ Query: 
    //  1. Data source. 
    int[] numbers = new int[7] { 0, 1, 2, 3, 4, 5, 6 };

    // 2. Query creation. 
    // numQuery is an IEnumerable<int> 
    var numQuery =
        from num in numbers
        where (num % 2) == 0
        select num;

    // 3. Query execution. 
    foreach (int num in numQuery)
        Console.Write("{0,1} ", num);

Have a look here as this might be a good place to start.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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