Databases Reference
In-Depth Information
this chapter, you are given an overview of the ADO.NET Entity Framework from a pure
data access prospective, avoiding the specifics related to ASP.NET web applications in
general or Dynamic Data in particular. If you are already familiar with Entity Framework
or LINQ to SQL, you can probably skip this chapter.
Understanding Entity Model
The ADO.NET Entity Framework is an Object-relational mapping (ORM) framework devel-
oped by Microsoft as part of the .NET Framework. It allows developers to define entities,
properties, and associations and map them to the underlying database tables and
columns. In version 4.0, you typically create the entities and mappings using the Entity
Designer in Visual Studio, which generates the application classes that can be used to
query the database with LINQ and manipulate database records in a form of .NET objects.
Creating Entity Model
To get started, you first need to add a new Entity Framework data model to your project
(in this chapter, we work with a simple Console Application project template). Select the
ADO.NET Entity Data Model item from the Data template category in the Add New Item
dialog of Visual Studio, as shown in Figure 2.1.
FIGURE 2.1 Adding ADO.NET Entity Data Model to a project.
After entering the file name and clicking Add, you see the Entity Data Model Wizard
shown in Figure 2.2, which prompts you to either generate the model from an existing
database or create an empty one. If the database already exists, choose the option to
generate the model. You can choose the option to create an empty model if you are lucky
enough to be working on a “green field” project for which the database does not yet exist
and you want to rely on the Entity Framework to generate the database for you. In this
 
 
Search WWH ::




Custom Search