How to connect mvc application using entityframework or ado.net

ado.netasp.net-mvcentity-framework

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?

Best Answer

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.