Introduction:
In this article,i am going to explain about how to use ado.net entity data model against sqldatabase in asp.net
application.
Main:
What is ado.net entity data model?
The Entity Data Model is an Entity-Relationship data model.(Its similar to linq to sql data class),
ADO.NET Entity Framework abstracts the relational (logical) schema of the data that is stored in a database and presents its conceptual schema to the application. For example, in the database, entries about a customer and their information can be stored in the Customers table, their orders in the Orders table and their contact information in yet another Contacts table. For an application to deal with this database, it has to know which information is in which table, i.e., the relational schema of the data is hard-coded into the application.
The disadvantage of this approach is that if this schema is changed the application is not shielded from the change. Also, the application has to perform SQL joins to traverse the relationships of the data elements in order to find related data. For example, to find the orders of a certain customer, the customer needs to be selected from the Customers table, the Customers table needs to be joined with the Orders table, and the joined tables need to be queried for the orders that are linked to the customer.
This model of traversing relationships between items is very different from the model used in object-oriented programming languages, where the relationships of an object’s features are exposed as Properties of the object and accessing the property traverses the relationship. Also, using SQL queries expressed as strings, only to have it processed by the database, keeps the programming language from making any guarantees about the operation and from providing compile time type information.
The mapping of logical schema into the physical schema that defines how the data is structured and stored on the disk is the job of the database system and client side data access mechanisms are shielded from it as the database exposes the data in the way specified by its logical schema.
How to use ado.net data entity model in asp.net application?
We can easily access the entity model like linq to sql,
masterEntities masterContext = new masterEntities();
var EmpNames = from p in masterContext.Emps
select p.FirstName;
foreach (var name in EmpNames)
{
MessageBox.Show (string.Format( "Employee name: {0}", name));
}
masterEntities masterContext = new masterEntities(); var EmpNames = from p in masterContext.Emps select p.FirstName; foreach (var name in EmpNames) { MessageBox.Show (string.Format( "Employee name: {0}", name)); } |
Conclusion:
Hope this helps,
Happy Coding








Dear admin, thnx for sharing this blog post. I found it wonderful. Best regards, Victoria…
Great information! I’ve been looking for something like this for a while now. Thanks!
Hi, i must say fantastic blog you have, i stumbled across it in AOL. Does you get much traffic?