Category Archives: Entity framework

Entity framework

What is Data Concurrency and Types of Concurrency Control in ADO.NET.

When multiple users attempt to modify data at the same time, controls need to be established in order to prevent one user’s modifications from adversely affecting modifications from simultaneous users. The system of handling what happens in this situation is called concurrency control. Types of Concurrency Control Three common ways to manage concurrency in a Continue Reading…

What is the difference between POCO, code first and simple EF approach?

All these three approaches define how much control you want on your Entity frame work code. Entity framework is an OR MAPPER it generates lot of code, it creates your middle tier (Entity) and Data access layer (Context). In Simple entity framework everything is auto generated and so you need the EDMX XML file as Continue Reading…

How to implement POCO in entity framework?

To implement POCO is a 3 step process:- Go to the designer and make the code generation strategy to NONE. This step means that you would be generating the classes with your own hands rather than relying on EF auto code generation. So now that we have stopped the auto generation of code , we Continue Reading…

What are POCO classes in Entity framework?

POCO means Plain old C# object. When EDMX creates classes they are cluttered with lot of entity tags. For instance below is a simple customer class generated using entity framework. Many times we would like to use simple .NET classes and integrate the same with entity framework. Entity framework allows the same. In other words Continue Reading…

How can we turn off lazy loading?

The opposite of lazy loading is eager loading. In eager loading we load the objects beforehand. So the first thing is we need to disable lazy loading by setting “LazyLoadingEnabled” to false. So now we have to explicitly tell EF what objects we want to load by using the “include” function. Below is a simple Continue Reading…

Can you explain lazy loading in a detailed manner ?

Lazy Loading is a concept where we load objects on demand rather than loading everything in one go. Consider a situation where you have 1 to many relationships between “customer” and “address” object. Now let’s say you are browsing the customer data but you do not want address data to be loaded that moment. But Continue Reading…

How can we read records using entity framework classes?

In order to browse through records you can create the object of the context class and inside the context class you will get the records. For instance in the below code snippet we are looping through list of customer object collection. This customer collection is a output given by the context class “CustomermytextEntities”.

What is the importance of T4 in Entity framework?

T4 files are heart in EF code generation. So the T4 code templates read the EDMX XML file and generate C# behind code. This C# behind code is nothing but your entity and context classes.   If you create a project using VS 2012, you will see the following hierarchy. At the top we have Continue Reading…