Extending the Entity Data Model Tools
You can extend the functionality of the ADO.NET Entity Data Model Tools by using classes in the Microsoft.Data.Entity.Design.Extensibility namespace to write Visual Studio extensions. Classes in the Microsoft.Data.Entity.Design.Extensibility namespace allow you to do the following actions:
Note |
---|
For code examples of the following extensions, see the ADO.NET Entity Data Model Designer Extension Starter Kit. |
Extend the .edmx file generation process.
The IModelGenerationExtension interface exposes the OnAfterModelGenerated method, which allows you to extend the functionality of the Entity Data Model Wizard.
Extend the .edmx file update process.
The IModelGenerationExtension interface exposes the OnAfterModelUpdated method, which allows you to extend the functionality of the Update Model Wizard.
Add custom properties to objects in the Entity Designer and Model Browser.
The IEntityDesignerExtendedProperty interface exposes the CreateProperty method, which allows you to add custom properties on objects visible in the Entity Data Model Designer (Entity Designer) and Model Browser, and make the properties visible in the Visual Studio Properties window.
Load and save custom file formats.
The IModelConversionExtension interface exposes the OnAfterFileLoaded and OnBeforeFileSaved methods, which allow you to load custom file formats, convert these files to an .edmx format, and save .edmx files in custom formats.
Extend the .edmx file loading and saving processes.
The IModelTransformExtension interface exposes the OnAfterModelLoaded and OnBeforeModelSaved methods, which allow you to customize the way the Entity Designer loads and saves .edmx files.
The functionality described above can be combined in one Visual Studio extension. For example, you could load a .uml file by using the OnAfterFileLoaded method (which will convert the file to an .edmx format), then modify the .edmx file with the OnAfterModelLoaded method before it is displayed in the Entity Designer. Conversely, you could modify a loaded .edmx file with the OnBeforeModelSaved method, then convert it to a .uml file with the OnBeforeFileSaved method before it is saved.
Also note that multiple implementations of the extension interfaces can be implemented in the same Visual Studio extension. For example, multiple implementations of the IModelTransformExtension interface could, in turn, make modifications to an .edmx file before it is displayed in the Entity Designer or before it is saved.
For information about writing Visual Studio extensions, see Developing Visual Studio Extensions and Managed Extensibility Framework (MEF).
For information about customizing other functionality of the Entity Data Model Tools, see How to: Customize Object-Layer Code Generation and How to: Customize Database Generation.