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?
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. |
|||||||||
|
You have to see these elements as layers of a cake.
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:
Have a look here as this might be a good place to start. |
|||
|