Write difference between LINQ and Entity Framework.
LINQ Entity Framework
In order to operate, LINQ In order to operate, the entity framework relies on
relies only on SQL Server several databases including SQL Server, Oracle,
Databases. MYSQL, DB2, etc.
In this case, an .edmx file is generated first, then
It generates a .dbml to
an .edmx file is maintained using three separate
maintain the relationship.
files- .csdl, .msl, and .ssdl.
DataContext enables you to ObjectContext, DbContext, and EntitySQL can all be
query data. used to query data.
Complex types are not
Complex types are supported.
supported.
A database is not created
A database can be created from the model.
from the model.
Application is developed Applications are developed more quickly using SQL
more quickly using SQL Server and other databases like MYSQL, Oracle, DB2,
Server. etc.
It consists of a tightly
It consists of a loosely coupled mechanism.
coupled mechanism.
Only one-to-one mappings One-to-one, one-to-many & many-to-many mappings
are allowed. are allowed.
It displays rapid It takes longer to develop than LINQ, but it provides
development. more capabilities.
Explain the term dbcontext and dbset.
DbSet: An entity set is represented by a DbSet class that can be used for creating,
reading, updating, and deleting operations on it. Those DbSet type properties, which
map to database tables and views, must be included in the context class (derived from
DbContext).
DbContext: It is considered an essential class in EF API that bridges the gap between an
entity or domain class and the database. Communication with the database is its primary
responsibility.