Generating the School .edmx File
In this task, you will learn to use the Entity Data Model Wizard to generate an .edmx file, which contains a conceptual model, a storage model, and mapping information. This file defines a set of 1:1 entity-to-table mappings for the School conceptual model and database. The School conceptual model is used throughout the Entity Framework getting started documentation.
-
Select Generate from database in the Choose Model Contents dialog box. Then click Next.
-
Click the New Connection button.
-
In the Choose Data Source dialog box, select your data source and then click Continue.
-
In the Connection Properties dialog box, enter your server name, select the authentication method, type School for the database name, and then click OK.
The Choose Your Data Connections dialog box is updated with your database connection settings.
-
Ensure that Save entity connection settings in App.Config as: is checked and the value is set to SchoolEntities. Then click Next.
The Choose Your Database Objects dialog box is displayed.
-
Select all tables and stored procedures and ensure that the value of Model namespace is SchoolModel.
Note: The stored procedures in the School model are required by many of the topics in the Entity Data Model Tools Scenarios. These walkthroughs start with the CourseManager application and School model created in this quickstart. -
Ensure that Pluralize or singularize generated object names and Include foreign key columns in the model are selected.
The wizard performs the following actions:
-
Adds references to the System.Data.Entity, System.Runtime.Serialization, and System.Security assemblies.
-
Generates the School.edmx file that defines the conceptual model, the storage model, and the mapping between them.
-
Creates an object-layer code file that contains the classes that were generated based on the conceptual model. You can view the object-layer code by expanding the .edmx file node in Solution Explorer.
Note: In Visual Basic projects, you must press the Show All Files button in the Solution Explorer before you can view the source code. -
Creates an App.Config file.
-
Adds references to the System.Data.Entity, System.Runtime.Serialization, and System.Security assemblies.
-
In the Solution Explorer, double-click the School.edmx file.
This displays the School model in the ADO.NET Entity Data Model Designer window, as shown in the following diagram.
-
From the View menu, select Other Windows, and then click Model Browser.
This displays the Entity Model Browser window.
-
Expand the SchoolModel and SchoolModel.Store nodes to view conceptual and storage content, respectively.
-
From the View menu, select Other Windows, click Mapping Details, and then click an entity or association in the Entity Designer.
This displays the Entity Mapping Details window with information about the conceptual-storage mapping for the selected object.