Entity Data Model Wizard
The Entity Data Model Wizard is used to generate an .edmx file. The Entity Data Model Wizard allows you to create a model from an existing database, or to generate an empty model.
The Entity Data Model Wizard starts after you add an ADO.NET Entity Data Model, item template to your project. The Entity Data Model Wizard then launches the ADO.NET Entity Data Model Designer (Entity Designer) after it finishes generating an .edmx file. For more information, see How to: Create a New .edmx File.
The Entity Data Model Wizard guides you through the following steps:
Choose Model Contents
Generate from database
, you can generate an .edmx file from an existing database.
, you can add an .edmx file that contains empty conceptual model, storage model, and mapping sections to your project. Select this option if you plan to use the Entity Designer to build your conceptual model and later generate a database that supports the model. For more information, see How to: Generate a Database from a Conceptual Model.
- By selecting Generate from database , you can generate an .edmx file from an existing database.
Choose Your Data Connection
Choose an existing connection from the drop-down list of connections, or click New Connection to open the Connection Properties dialog box and create a new connection to the database.
If you are logging onto the database server by using SQL Server Authentication, you must decide whether to include sensitive data (such as user name and password) in the connection string, or whether you will handle the sensitive data in your application code. Select the option that corresponds to your choice. For more information about security issues when you use connection strings, see Connection String Security.
The Entity Connection String box displays the connection information based on your server and database connection selections.To save entity connection settings in the App.Config or Web.Config file (depending on the project type), select Save the entity connection settings . Type a name for the connection or use the provided default name.
Note: Visual Studio Express Editions cannot connect to a server. They can only connect to a file instance of a database.
Saving connection strings in the configuration file simplifies maintaining your application if the database connection changes. If the database connection changes, you can edit the connection string in the configuration file. This means that you do not have to edit the source code and recompile the application. If you do not save the connection string, you will have to pass the connection string into one of the DbContext or ObjectContext constructors to execute queries.
Note: Information is stored in the App.Config or Web.Config file as plain text. To reduce the risk of unauthorized access to sensitive information, you might want to encrypt your data.
Choose Your Database Objects
The Choose Your Database Objects dialog box appears after you have selected the server and database to use. This dialog box displays the tables, views, and stored procedures that are available to include in the .edmx file.
Select the objects to include in the .edmx file. By default, no objects in the database are selected.If you do not want the wizard to apply English-language rules for singulars and plurals to Entity , EntitySet , and NavigationProperty names, clear the Pluralize or singularize generated object names checkbox. If you proceed with the checkbox checked, the wizard will do the following:
Note: If you choose to include stored procedures, the wizard modifies the storage model accordingly. However, you must use the Model Browser to create the corresponding conceptual model entries. For more information, see How to: Import a Stored Procedure or How to: Map Modification Functions to Stored Procedures.
Provide a namespace name in the Model Namespace box. The namespace name is used in the conceptual model, storage model, and generated source code file. The namespace must be unique for the project. The wizard checks if the project has a conceptual model with the same namespace and makes the namespace unique by adding a "0", "1", and so on, to the namespace name.
that returns at most one entity, make the name singular.
that returns more than one entity, make the name plural.
Note: If a database table contains only foreign keys (sometimes called a pure join table), the wizard will not generate a corresponding entity type nor will it generate properties on related entity types that correspond to the foreign keys. Instead, a many-to-many association will be generated between the two entity types that the pure join table links.
Any errors, warnings, or messages that are generated by the wizard will be visible in the Error List after the wizard closes.
Note: If no objects are selected, or if there are no objects in the selected database, a message appears that asks you if you want to create an empty model. If you click yes, the wizard creates an empty model, adds a connection string to the App.Config or Web.Config file, and creates a default model namespace.
- Make all EntityType names singular.
Upon closing, the Entity Data Model Wizard creates an .edmx file that contains the model information. The .edmx file is used by the Entity Designer, which enables you to view and edit the conceptual model and mappings graphically.
The Entity Data Model Wizard also creates a source code file that contains the classes that are generated from the CSDL content of the .edmx file. The source code file is automatically generated and is updated when the .edmx file changes. For more information, see Generated Code Overview.
|Earlier versions of the Entity Data Model Wizard referred to .csdl, .ssdl, and .msl files. The information in these files is now encapsulated in the .edmx file. The .csdl, .ssdl, and .msl files can be embedded in an output assembly (the default) or copied to the output directory. (For more information, see How to: Copy Model and Mapping Files to the Output Directory.) The .csdl, .ssdl, and .msl files are not intended to be edited. Any modifications to the conceptual model, storage model, or mappings should be made to the .edmx file by using the ADO.NET Entity Data Model Designer or the XML Editor.|
Other ResourcesADO.NET Entity Data Model Designer