Monday, May 18, 2015

Entity framework interview questions?

Posted by Rahul Kharde at 9:59 AM

 Explain what is ADO.NET entity framework?

·         "Entity framework is a type of ORM (object relationship model) that connects classes with database objects". It makes it easier to work with databases and tables without worrying about columns and rows. ORM makes it easier for you to query databases using LINQ, and you do not need to worry about your database connection. Additionally, you can create programs that are unaware of the database and its connection or type (Oracle, SQL Server or MySQL). Entity framework takes care of all of the back-end connection so you can worry about the queries and data.

·         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

·         It 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. 

·         EF 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.

Explain what does .edmx file contains?

.edmx(Entity Data Model Extension) 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.

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

Explain why T4 entity is important in Entity Framework?

T4 (Text Template Transformation Toolkit) is a template based code generation engine. You can go and write C# code in T4 templates (.tt is the extension) files and those C# codes execute to generate the file as per the written. It also reads the EDMX XML file and generates C# behind

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

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

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.

What is lazy loading?

Lazy loading is a way to return only objects that are used. When you query the database model, lazy loading only returns the immediate tables needed by the user. All related tables are returned when they are used. This means you can reserve memory and storage when you work with large programs. It also means that objects are created until you need them, so it makes your program faster.

What is eager loading?

Eager loading is the opposite of lazy loading. When you query for objects, eager loading returns all of the objects including the related objects. For instance, when you query a list of customers and orders, eager loading loads all objects including the customers and the orders instead of just what you originally need (customers).

What is a complex data type?

A complex data type occurs when you need to point to another data object from one data object. For instance, if you have several tables that require an address, you can turn those addresses into a table of addresses. You then point your address columns to the new address table, which creates a complex data type. You will likely have complex data types in every .NET Entity framework project, because it makes it easier to relate one table and data model to another without creating cumbersome code.

If you enjoyed this post and wish to be informed whenever a new post is published, then make sure you subscribe to my regular Email Updates. Subscribe Now!

Kindly Bookmark and Share it:



Have any question? Feel Free To Post Below:


Popular Posts

Recent Comments

© 2011. All Rights Reserved | Help to understand .Net | Template by Blogger Widgets

Home | About | Top