Entity Framework with LINQ to SQL

Source: Internet
Author: User

What is the difference between the Entity Framework and LINQ to SQL? This is a very common problem. The main differences between the two technologies are briefly outlined in the table below.


LINQ to SQL

Entity Framework

Complexity of

Relatively non-complex

Relatively complex

Model

Domain model

Conceptual Data Model (conceptual)

Database server

SQL Server

Multiple database Products

Development time

Rapid Application Development

Takes a long time, but supports more features

Inherited

Difficult

Easy

File type

DBML file

EDMX,CDSL,MSL,SSDL file

Complex Type Support

Not supported

Support

Query capabilities

by DataContext

ESQL, Object Services, Entity Client

Performance

Slow first Query

The first query is also slow, but overall excellent with LINQ to SQL

Perfect

No more new versions

and a new version.

Generating a database from a model

Not supported

Support

complexity: More features are more complex to support. LINQ to SQL supports fewer features, so it's relatively less complex, and EntityFramework supports more features, so it's relatively complex.

Model: LINQ to SQL provides a one-to-one mapping between a data table and a class. If you have customers,orders, and lineitems tables, you will have Customer,order, and LineItem classes to match each table. EntityFramework allows you to have a customer class, and this class can match multiple tables. This means that the company name can be in one table, but the address is in another table, and the phone number is in another table, and so on.

Database server: LINQ to SQL supports only Microsoft SQL Server 2000 and later versions, but even SQLServer2000 has many limitations. EntityFramework can support IBMDB2, Sybase Sqlanywhere, Oracle, Sqlazure, and many others.

Development Time: LINQ to SQL is easy to learn and fast to develop, but LINQ to SQL has some limitations that can create problems when developing more complex applications. EntityFramework is more capable, although learning and application is slower, but support for more features makes it possible to minimize problems when developing more complex applications.

Inheritance: LINQ to SQL supports TPH, while EntityFramework supports TPH and TPT, and is partially supported for TPC.

file type: the LINQ to SQL uses a Database markup Language (DBML) file that contains XML to map entity and data tables. EntityFramework uses four files. The first one is the entity Data Model (EDMX), which is used in the designer. The edmx file produced the other three files at the time of compilation. The first of the other three files is the Conceptualschema definition Language (CSDL) file, which contains the XML definition of the conceptual model. The second is a schemadefinition Language (SSDL) file that contains the definition of the storage model. The third file is the mapping specification Language (MSL) file, which contains a mapping between the conceptual model and the storage model.

Complex Type support: For example, a customer has a phone number, but you want the phone number to be defined as country code, area number, city area code, number, and extension number. Linqto SQL does not support this complex type, while EntityFramework supports it.

Query Ability: LINQ to SQL queries the database through DataContext. EntityFramework is queried through the ObjectContext through linqto entities. The Entity framework also provides ESQL, a SQL-like query language that is ideal for defining queries in model definitions. EntityFramework also contains the ObjectQuery class for object services to dynamically create queries at run time. The final entityframework also contains Entityclientprovider, which is used to query the conceptual model.

Performance: LINQ to SQL and the Entity Framework are slow to execute queries for the first time, but later performance is more satisfying. EntityFramework performance is slightly better than linqto SQL.

Perfect: Microsoft has stopped releasing new LINQ to SQL after releasing the Entity Framework, but because of the simplicity of Linqto SQL it is still popular, so Microsoft will continue to support and feedback to linqto SQL users. However, Linqto SQL will no longer publish a new version for refinement.

To generate a database from a model: LINQ to SQL does not have the ability to generate a database from a model. The Entity framework supports two types of development patterns, database first and coding first. The database is first developed and the database already exists, so it is not necessary to generate the database from the model. Coding takes precedence, you create your model first, and then the database is generated by the model.

Entity Framework with LINQ to SQL

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.