ADO.Net Entity Framework

  Home  Microsoft .Net Technologies  ADO.Net Entity Framework


“Entity Framework frequently Asked Questions by expert members with experience in ADO.Net Entity Framework. These interview questions and answers on Entity Framework will help you strengthen your technical skills, prepare for the interviews and quickly revise the concepts. So get preparation for the Entity Framework job interview”



28 ADO.Net Entity Framework Questions And Answers

1⟩ What is Entity Framework?

The Microsoft ADO.NET Entity Framework is an Object/Relational Mapping (ORM) framework that enables developers to work with relational data as domain-specific objects, eliminating the need for most of the data access plumbing code that developers usually need to write. Using the Entity Framework, developers issue queries using LINQ, then retrieve and manipulate data as strongly typed objects. The Entity Framework’s ORM implementation provides services like change tracking, identity resolution, lazy loading, and query translation so that developers can focus on their application-specific business logic rather than the data access fundamentals.

To simply say it: Entity framework is an Object/Relational Mapping (O/RM) framework. It is an enhancement to ADO.NET that gives developers an automated mechanism for accessing & storing the data in the database and working with the results in addition to DataReader and DataSet.

Now the question is what is O/RM framework and why do we need it?

ORM is a tool for storing data from domain objects to relational database like MS SQL Server in an automated way without much programming. O/RM includes three main parts: Domain class objects, Relational database objects and Mapping information on how domain objects maps to relational database objects (tables, views & storedprocedures). ORM helps us to keep our database design separate from our domain class design. This makes application maintainable and extendable. It also automates standard CRUD operation (Create, Read, Update & Delete) so developer doesn’t need to write it manually.

 201 views

2⟩ What are differences between Entity Framework and L2S?

Entity framework has a full provider model. It supports not only SQL Server but also other database like Oracle, DB2, MySQL etc.

Most of the time L2S classes must be one-to-one with database objects e.g. Customer class can be mapped only with Customer table. Where as in Entity Framework you can map your domain class with multiple tables using various inheritance strategies like table per type (class) or table per hierarchy of classes etc.

You can have multiple modeling techniques using Entity Framework 4.1 like code first, model first or database first.

Microsoft has long term strategy to support and integrate Entity Framework with multiple Microsoft products.

 193 views

4⟩ What is Conceptual Model?

Conceptual model is your model classes and their relationships. This will be independent from your database table design.

 199 views

5⟩ What is Storage Model?

Storage model is your database design model which includes tables, views, stored procedures and their relationships and keys.

 217 views

7⟩ Explain LINQ to Entities?

LINQ to Entities is query language used to write queries against the object model. It returns entities which are defined in the conceptual model. You can use your LINQ skills here.

 213 views

8⟩ What is Entity SQL?

Entity SQL is again a query language same as LINQ to Entities. However it is little more difficult than L2E and also developer need to learn it separately.

 214 views

9⟩ What is Object Service?

Object service is a main entry point for accessing data from database and to return it back. Object service is responsible for materialization which is process of converting data returned from entity client data provider (next layer) to an entity object structure.

 207 views

10⟩ What is Entity Client Data Provider?

The main responsibility of this layer is to convert L2E or Entity SQL queries into SQL query which is understood by underlying database. It communicates with ADO.Net data provider which in turn sends or retrieves data from database.

 204 views

12⟩ What is EDM Designer?

EDM designer represents your conceptual model. It consists Entities, associations & multiplicity between the entities. Initially it will exactly look like your database table structure but you can add or merge columns or remove columns which are not required by your application from this designer. Even you can add new object in this model which can have columns from different database tables from context menu as shown in above figure. Remember, whatever changes you do here it should be mapped with storage model. So you have to be careful while doing any changes in the designer.

 210 views

13⟩ What is EntityContainer?

EntityContainer is a wrapper for EntitySets and AssociationSets. It is critical entry point for querying the model.

 212 views

14⟩ What is EntitySet?

EntitySet is a container for EntityType. It is set of same entitytype. You can think it like db table.

 251 views

15⟩ What is EntityType?

EntityType is a datatype in the model. You can see each EntityType for your conceptual model in XML. If you expand EntityType node in XML, you can see each properties and its type and other info.

 220 views

17⟩ What is ObjectContext?

Now, if you open designer.cs, you can see two main regions, Contexts and Entities. Expand contexts region. You can see partial class with suffix ‘entities’ and derived from ObjectContext class.

 218 views

18⟩ What is ObjectSet?

Each EntitySet in context class is a type of ObjectSet<> that wraps the entity. e.g. ObjectSet.

 223 views

19⟩ What is IObjectSet?

IObjectSet is a interface which gives collection like functionality. ObjectSet<> also implements IObjectSet. IObjectSet is useful in unit testing where you can create fake EntitySet (of type IObjectSet<>). We have used IObjectSet in our sample project.

 220 views

20⟩ What is EntityTypes?

Now if you expand ‘Entities’ region, you can see many partial classes that are derived from EntityObject. This classes are EntityTypes of you model.

 237 views