Database Reference
In-Depth Information
Of course, there's more to the designer and model than just the few key parts illustrated in Figure 1-6 . In the
recipes in this topic, we'll cover just about every aspect of using the designer to create models. In some cases, we go
beyond what can be done with the designer and show you how to create models that require direct editing of the
underlying .edmx file. The .edmx file contains the complete model definition, including the conceptual layer, store
layer, and mapping layer.
So, whether we implement Entity Framework with the Database-First, Model-First or Code-First approach,
we always end up with a model. We gain significant productivity, as we can program against objects in the model
(EntityTypes) as you do with other objects in your application. For the model in Figure 1-6 , your code uses Customer
and Order in much the same way as you use other objects.
If you want to insert a new customer and order into the database, you can create instances of the Customer
and Order types, set the properties, add them to the in-memory context that represents the model, and call
SaveChanges() . All the necessary SQL code is generated and sent to the database to insert the rows. To retrieve
customers and orders from the database, you use either LINQ or Entity SQL to create a query in terms of the
EntityTypes and associations in the model.
The recipes throughout this topic will show you step by step how to model just about every conceivable database
scenario; how to query, insert, update, and delete using these models; and how to use Entity Framework in many
kinds of applications.
 
Search WWH ::




Custom Search