I was checking 2nd edition of Professional ASP.NET MVC and realized EF replaced LINQ to SQL. I am familiar to LINQ to SQL from the first book but I know nothing about EF. Anyway while reading the code, it seems like nothing has changed except the name. Same old repository classes, same old functions.
I did a little research. I know LINQ is not limited to SQL. Also EF is not limited Microsoft-family SQL servers. In this 2 year old question people are not happy with EF, saying it's overcomplicated and all. But now I'm reading same code under EF name. Only classes are generated with ADO.NET Entity Model insted of LINQ to SQL. Can anybody clear out the fuss about EF features since it's the de facto standart ORM now?
Entity Framework Core uses Language-Integrated Query (LINQ) to query data from the database. LINQ allows you to use C# (or your . NET language of choice) to write strongly typed queries.
Answer. Entity framework allows you to query and modify RDBMS like SQL Server, Oracle, DB2, and MySQL, etc., while LINQ to SQL allows you to query and modify only SQL Server database by using LINQ syntax. Works with various databases like Oracle, DB2, MYSQL, SQL Server, etc. Supports the complex type.
Entity Framework is an ORM -> a Mapper to help you get data. asp.net is a framework to STRUCTURE your project ,with Objects and Classes, not related to entity.
They are somewhat similar, and can be used in a very similar way, code-wise, but they have some important differences. Note that "LINQ" is not the same thing as "LINQ to SQL"; the EF also uses LINQ. Some notable differences are:
EF came of age with v4.0. Before that, it was a bit of a pain to use, and I didn't recommend it. Now my recommendation is that all new LINQ-to-DB code use EF4.
As far as new features go, the LINQ part is actually quite similar to LINQ to SQL. But it's quite a different architecture: EF4 acts as a LINQ provider to an (EF) ADO.NET provider which then wraps another ADO.NET provider. So there's new things like Entity SQL (which I don't use), and EF supporting different underlying ADO.NET providers (which I do use).
The XML modeling system that EF uses allows more powerful mapping abstractions, as well. One that I use regularly is having different tables with the same primary keys mapping to an entity inheritance relationship; from what I understand, the only way to do this in LINQ to SQL is via a "selector column" (though I never tried this in LINQ to SQL).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With