varunmaggo's say

Getting better never stops!

Archive for the ‘Entity Framework 4’ Category

Object Context in Entity Framework 4

leave a comment »

What is Object Context?

It is a class which manages the DB connection, and the different Entities of our model.

When Visual Studio creates the EF model, like I explain previously, also generates a Class that extends ObjectContext.

ObjectContext provides:

- DB connection

- Add, update and delete functions.

- Object Sets of Entities.

- State of Pending Changes.

This class will give a function, for each Entity, like

Esta clase va a contar con una función, para cada entidad, del tipo “AddTo{ENTITY}({Entity_Type } value)”, which are going to add a Entity to the related ObjectSet.

In addition, it has a property, for each Entity, like “ObjectSet Entity”, does will keep the related record set. It will be filled with the CreateObjectSet function of Base class (ObjectContext).
What is an ObjectSet?

It is a class that allows us to manage the Entity Set from a Type.

It inherits from:

· ObjectQuery

· IObjectSet

· IQueryAble<TEntity

· IEnumerable<TEntity

· IQueryAble

· IEnumerable

An ObjectSet is a class property that allows query, insert, delete and update records from a determinate Entity.

In following chapters we will see how to query Entities.
LazyLoadingEnabled

A very important property of the Context is “LazyLoadingEnabled”. This Boolean property lets indicate if the data loading is lazy, in other words, the Object will not be created and query until not be needed.

Written by Varun Maggo

March 17, 2011 at 11:39 am

ADO.NET Entity Connection String for Multiple Projects

leave a comment »

I was working with Entity Framework 4 with 3 tier logical arhitecture, during runtime i get an error :- “The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid.”

Solution: we need to set the appsettings, i fixed this issue with updating my root web.config.

Also Make sure, you have added the reference, System.Data.Entity (Data Tier and Business Tier)

Hope this helps, Someone Somewhere :)

Written by Varun Maggo

March 16, 2011 at 8:12 am

Follow

Get every new post delivered to your Inbox.