We had compiled most frequently asked entity framework interview questions and answers for freshers and experienced dot net developers on Entity framework basics, architecture, Data Model, Client Data Provider, DB Context, difference between framework, LINQ & SQL etc.
Entity Framework is an ORM from Microsoft that will enable the developers to work with domain specific objects, which eliminates the extra code being written in the data access layer.
|ADO.NET is faster.||"Entity Framework will be around the ADO.NET, which means ADO.NET is faster than Entity Framework."|
|We need to write so much code to talk to database.||Easy to use. As an Entity Framework will talk to database without much code involved.|
|Performance is better than Entity Framework.||Performance is not good compared to ADO.NET.|
4) What is the difference between Entity Framework and LINQ to SQL?
|LINQ to SQL||Entity Framework|
|Supports only for SQL database.||"Supports databases like SQL, MySQL, DB2 etc."|
|Allows only one-to-one mapping between the entity classes and the relational tables.||Allows one-to-one, one-to-many & many-to-many mappings between the Entity classes and the relational tables.|
|.dbml file is generated for maintaining the relationships.||Relationships are maintained in 3 different files - .csdl, .msl and .ssdl|
|No Support for Complex Types||Supports Complex Types|
|Supports Rapid application development with SQL Server.||Supports Rapid application development with SQL Server, DB2, MySQL etc.|
5) What are the components of Entity Framework Architecture?
Below are the components of Entity Framework –
- Entity Data Model (EDM)
- LINQ to Entities
- Entity SQL
- Object Service
- Entity Client Data Provider
- ADO.Net Data Provider
6) What are the parts of Entity Data Model (EDM)?
Below are the parts of Entity Data Model –
- Conceptual Model
- Storage Model
7) How to create Entity Data Model (EDM)?
Add New Item -> ADO.NET Entity Data Model, which generates file with .edmx extension.
8) What does .edmx consists of?
.edmx file is a XML file and it has Conceptual Model, Storage Model and Mapping details i.e,
- SSDL (Store schema definition language)
- CSDL (Conceptual schema definition language)
- MSL (Mapping specification language)
9) What is Conceptual Model?
Conceptual Models are the model classes which contain the relationships. These are independent of the database design.
10) What is Storage Model?
Storage Models are our database design models, which contains database tables, views, stored procs and keys with relationships.
11) What is Mapping?
The Mapping will have the information on how the Conceptual Models are mapped to Storage Models.
12) What is LINQ to Entities?
LINQ to Entities is a query language which we used to write queries against the object models and the query result will return the entities defined in the Conceptual Model.
13) What is Entity SQL?
Entity SQL is a query language is like LINQ to Entities. This is a bit complex compared to LINQ to Entities. A developer who is using this should learn this separately.
14) What is the role of Entity Client Data Provider?
Responsibility of Entity Client Data Provider is to convert the LINQ to Entities or Entity SQL queries to a SQL query, which is understood by the underlying database. This finally communicates with ADO.NET Data Provider which in turn used to talk to the database.
15) What is the meaning of Pluralize and Singularize in Entity Framework?
Pluralize and Singularize gives the meaningful naming conventions for objects.
We will get this option while adding an edmx file. On selecting this option Entity Framework will adhere to Singular or Plural coding conventions.
16) What is DB Context ?
When we create a edmx file, it will have the list of entities and context class which will be derived from DB Context class.