This topic introduces the Entity Data Model (EDM) Designer which is a Visual Studio tool for defining conceptual entities and mapping them to the database.
The EDM Designer is a Visual Studio design tool for defining your Entity Data Model (EDM). It reads and updates the EDMX file that represents the model in XML. Every DevForce developer who is responsible for writing and maintaining an Entity Framework EDM will use this tool.
When you have created a new EDM with the EDM Wizard, the wizard leaves you in the EDM Designer. If you chose the "Data First" approach and generated the initial model from a database schema, the EDM Designer might look a bit like this:
By default, DevForce code generation is not enabled until you switch it on. Before going any further with the model, it's a good idea to switch it on now.
To do so, first click within the EDM designer canvas so that the entire conceptual model is displayed. Then open the Model Properties window, either by hitting F4 or choosing "Properties" from the context menu. Once open, sort the properties by category and locate the "DevForce Enabled" property. Set it to "True".
You may also want to set the Code Generation Strategy to Default now too. This helps ensure the connectionString isn't "lost", as we'll discuss further below. You'll find this property under the "Code Generation" category.
In Visual Studio 2012 and above, an EF Code First model is generated by default for all new models created with the EDM Designer. Since we want DevForce to generate our model and not EF, we need to remove the EF-generated files. When DevForce is enabled, it will remove these files for you.
Unfortunately, EF may not have written the connectionString for your model to the .config file. Check now to ensure the .config file in your model project contains the connectionString for this model. If not, you can do an "Update Model From Database" within the EDM designer to reset it. Alternately, copy the connection string you see in the Model Properties window, and paste it into the .config file.
You may be completely satisfied with the model as it was initialized from the database schema in which case your next stop might be to review the generated entity classes and start customizing them with your own business logic.
Most developers adjust the EDM here in the designer in order to shape the entities to meet their needs. They may want to
The basic workflow for such changes is:
Some of the object properties that you set in the designer are actually DevForce-specific properties. They were added by the DevForce EDM Designer Extension when you installed DevForce itself.
You probably shouldn't model every table in the database all at once. You'll add new entities over time and, if you use the Data-First approach, you'll want to initialize those entities and their mappings from information in the database just as you did when you first created the model with the EDM Wizard.
When you change the database, you may need to change the EDM to match.
Don't start over. Use the Update Model Wizard described here.
The Microsoft documentation in MSDN is a place to start.
Microsoft-sponsored Entity Framework videos are short, excellent guides to building entity models with the EDM Designer.
Julie Lerman's Programming Entity Framework, 2nd edition is authoritative on Entity Framework matters in general and the EDM Designer in particular. Julie's blog will keep you on top of the latest EF techniques.