0% found this document useful (0 votes)
321 views

Questions & Answers

The document discusses ADO.NET Entity Framework and provides answers to 16 common interview questions about it. Some key points covered include: Entity Framework is an ORM framework that provides automated mapping between objects and database tables; it reduces development time by automatically generating code; and it supports code-first, model-first, and database-first approaches to development.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
321 views

Questions & Answers

The document discusses ADO.NET Entity Framework and provides answers to 16 common interview questions about it. Some key points covered include: Entity Framework is an ORM framework that provides automated mapping between objects and database tables; it reduces development time by automatically generating code; and it supports code-first, model-first, and database-first approaches to development.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

https://career.guru99.

com/

Top 16 ADO.NET Entity Framework Interview


Questions & Answers

1) Explain what is ADO.NET entity framework?

ADO.NET entity framework is an ORM (Object Relational Mapping) framework developed by Microsoft.
It is an extension of ADO.NET that provides an automated mechanism to access and store data in the
database. With the help of ADO.NET, database can be accessed without much required programming
or code.

2) Mention what is the key advantage of using Entity Framework or EF?

The main advantage of using Entity Framework or EF is that it generates code automatically for the
Model (Middle Layer), Mapping code and Data Access Layer. It reduces a lot of time during the
development process.

3) Mention in what all scenarios Entity Framework can be applicable?

Entity Framework can be applicable in three scenarios

If you have existing database already or you want to build your database first than other parts
of the application
If your prime focus is your domain classes and then create the database from your domain
classes
If you want to design your database schema on the visual designer and create the classes and
database

4) Explain what does .edmx file contains?

.edmx file is an XML file, which declares a conceptual model, a storage model and the mapping
between these models. This file also consists the information that is used by ADO.NET entity data
model designer to render a model graphically. It consists of all the mapping details of how object
maps with SQL tables. It is divided into three categories SSDL, CSDL, and MSL.

5) Mention what is CSDL, SSDL and MSL sections in an EDMX file?

CSDL: It stands for Conceptual Schema Definition Language, it is the conceptual


abstraction which is exposed to the application
SSDL: It stands for Storage Schema Definition Language, it defines the mapping with our
RDBMS data structure
MSL: It stands for Mapping Schema Language, it connects the SSDL and CSDL
6) Mention what is the difference between LINQ to SQL and Entity Framework?

LINQ to SQL Entity


• It works with various database like
DB2, MYSQL, SQL Server etc.
• It works only with SQL Server Database
• It creates an .edmx files initially and
• To maintain the relation it generates a
relation is maintained using 3 different
.dbml
files .msl, .csdl and .ssdl
• It cannot generate database from model
• It can generate database from model
• It permits one to one mapping between
• Between the entity classes and
the entity classes and relational
relational tables, it permits one-to-one,
views/tables
one-to-many and many-to-many
• It enables you to query data using
• It enables you to query data using
DataContext
EntitySQL, DBContext, and
• It provides tightly coupled approach
ObjectContext
• It provides loosely coupled approach

7) How can you enhance the performance of Entity Framework?

To enhance the performance of Entity Framework, you have to follow the following steps

Try to avoid to put all the DB objects into one single entity model
Disable change tracking for entity if not needed
Reduce response time for the first request by using pre-generating Views
If not required try to avoid fetching all the fields
For data manipulation select appropriate collection
Wherever needed use compiled query
Avoid using Views and Contains
While binding data to grid or paging, retrieve only required no of records
Debug and Optimize LINQ query

8) Explain why T4 entity is important in Entity Framework?

T4 entity is important in Entity framework as it is the heart of entity framework code generation. It
reads the EDMX XML file and generate C# behind code.

9) Explain how you can load related entities in EF (Entity Framework)?


You can load related entities or data in EF in three ways

Eager Loading
Lazy Loading
Explicit Loading

10) Mention what is Code First approach and Model First Approach in Entity Framework?

In Entity Framework,

Model First Approach: In this approach we create entities, relationships directly on the
design surface of EDMX.

Code Approach: For code approach we avoid working with the visual designer or entity
framework.

11) Explain Lazy loading, Eager Loading, and Explicit Loading?

Lazy Loading: It is a process to delay the loading of related objects until it is required.
Eager Loading: It occurs when you query for an object and all of the related objects are also
returned. In eager loading, related objects are loaded automatically with its parent object
Explicit Loading: Explicitly loading takes place when you have disabled Lazy loading, and
you still want to lazy loading. For this, we have to call the load method on the related entities.

12) Mention what is the difference between ADO.NET and classic ADO?

In NET, we have data-set while ADO we have record-set


In record-set we can only have one table and to insert more than one table you have to do
inner join. While the dataset in ADO.NET can have multiple tables
In NET, all data persist in XML while in classic ADO the data persists in binary format also

13) What is the namespace used to include .NET Data provider for SQL server in .NET
code?

The namespace System.Data.SqlClient is used to include.NET data provider for SQL server in .NET
code.

14) Mention what are the various methods provided by the DataSet object to generate
XML?

To generate XML various DataSet object include

ReadXml () : It reads XML document into DataSet object


GetXml () : It returns string consisting an XML document
Write Xml () : It writes an XML data to disk

15) Mention what is DataAdapter class in ADO.NET?

In ADO.NET data-adapter class fetch data from the database, stores data in a dataset and reflects the
changes made in the dataset to the database. For all type of communication, data-adapter act as an
intermediary. Using the Fill() method, data-adapter fills data to a Data-table.

16) Explain what is connected and dis-connected data access in ADO.NET?

Connected data access: Through the DataReader objects of data-provider you can have
connected data access. It provides fast access to data, and it does not allow editing.
Dis-connected data access: Through the DataAdapter object, disconnected data access is
achieved. The dataset works independently of the database, and the data is editable.

Guru99 Provides FREE ONLINE TUTORIAL on Various courses like

Java MIS MongoDB BigData Cassandra

Web Services SQLite JSP Informatica Accounting

SAP Training Python Excel ASP Net HBase

Project
Test Management Business Analyst Ethical Hacking PMP
Management

Live Project SoapUI Photoshop Manual Testing Mobile Testing

Data Warehouse R Tutorial Tableau DevOps AWS

Software
Jenkins Agile Testing RPA JUnit
Engineering

Selenium CCNA AngularJS NodeJS PLSQL

You might also like