Over the past few years, a team at Microsoft has been building and enhancing ADO.NET Entity Framework, which was first introduced in version 3.5 of .NET. The Entity Framework allows you to develop applications that utilize a model designed to sit between the actual data storage schema and the user interface within an ASP.NET application.
While it might seem this adds another tier to web applications, the fact is the Entity Framework model acts as a substitute for what would be the logic tier.
You have the choice to either generate an empty model or through an existing database. Consider the example below that demonstrates the model generation process from a BibleStore database.
You begin by adding an Entity Framework model to a project, which is selected from the Data templates column:
Once the model is added, you can link it with an existing database in the exact same fashion as you would add a data control (such as a Data Source). This image illustrates connecting to a SQL Express database.
When you’ve finished connecting to the database, it’s simply a matter of specifying the views, stored procedures and tables you want to include in the model. The views and tables act as the class objects. Stored procedures are viewed as methods, tying the Entity Framework model together so that the application can take full advantage of interacting with any existing data logic.
Querying Entity Framework with LINQ
Now you have a model you can query using LINQ. This significantly speeds up development time as well as the application. You will also note that the model tracks relationships between the tables, as illustrated by the line drawn between the Publisher and Bible tables to show the 1 to many relationship of the entities.
There’s no question the ADO.NET Entity Framework can make development faster, safer and more scalable. But more importantly it makes developing data-drive web and desktop applications much easier. It is also data provider agnostic, so you can potentially use it to interact with Oracle, MySQL, PostgreSQL and others. The ADO.NET Entity Framework (currently at version 4.3.1) is truly becoming a “model way” (hee, hee — pun intended) for working with data. God bless and happy coding!