Database Reference
In-Depth Information
Chapter 2
Entity Data Modeling Fundamentals
More likely than not, you are just beginning to explore Entity Framework, and you are probably asking the question,
“Okay, how do I get started?” If this describes you, this chapter is a great place to start. If, on the other hand,
you have built some working models and feel comfortable with a few key modeling concepts, such as entity splitting
and inheritance, you can skip this chapter.
In this chapter, we will walk you through the basic examples of modeling with Entity Framework. Modeling is
the core feature of Entity Framework and what distinguishes Entity Framework from previous Microsoft data access
platforms. Once you have built your model, you can write code against the model rather than against the rows and
columns in the relational database.
We start off this chapter with an example of how to create a simple conceptual model, and then let Entity
Framework create the underlying database. In the remaining examples, we will show you how to create models from
existing tables and relationships in your databases.
2-1. Creating a Simple Model
Problem
You have a brand new project, and you want to create a model.
Solution
Let's imagine that you want to create an application to hold the names and phone numbers of people that you know.
To keep things simple, let's assume that you need just one entity type: Person.
To create the new model, do the following:
1.
Right-click your project, and select Add New Item.
2.
From the templates, select ADO.NET Entity Data Model and click Add. This template is
located in Data under Visual C# Items (see Figure 2-1 ).
 
Search WWH ::




Custom Search