Ways to Invoke the Model Editor
- 6 min to read
The Model Editor can be used both at design time (in Visual Studio by a developer) and at run time (by application users and administrators). While the Model Editor invoked at design time is represented by a window pane in Visual Studio, the Model Editor invoked by end-users and administrators is represented by a form. The elements and capabilities in both these Model Editor representations are primarily the same. This topic describes how to invoke the Model Editor in different scenarios and is comprised of the following sections.
- Invoke the Model Editor in the Visual Studio at Design Time
- Invoke the Model Editor via the Edit Model Action At Run Time
- Deploy and Run the Standalone Model Editor
Invoke the Model Editor in the Visual Studio at Design Time
In Solution Explorer, double-click the Model.xafml or Model.DesignedDiffs.xafml file contained in the XAF solution's project (module or application project).
Also you can right-click the project and choose Open Model Editor in the context menu.
The Model Editor will be invoked in a window pane.
The model editor pane contains the nodes tree, property grid and the search pane (optionally). You can switch focus through these UI elements by pressing the TAB key. A description, type and a declaring interface of the currently selected node/property is displayed at the bottom.
For different projects, different information will be displayed. This information is collected from the modules that are added to the project for which you invoked the Model Editor. In addition, if this project is a module, the information the module itself is loaded as well. To see the list of loaded modules, see the corresponding Module Designer or Application Designer.
Everything you change in the Model Editor is saved to the Model.xafml or Model.DesignedDiffs.xafml file, depending on whether the changes were made in an application project or in a module. Changes are displayed in bold in the Model Editor. You can view the underlying XML code by right-clicking the XAFML file and choosing View code. These changes are superimposed on previous values loaded to the Application Model. Values specified in the Model Editor for the application project are the Application Model's final values. They are used when starting the application. For details, refer to the Application Model Basics topic.
Invoke the Model Editor via the Edit Model Action At Run Time
When the Edit Model or Administrative permission is granted to the current user, the EditModel Action is available in the Tools category of the WinForms application's root window. This Action is always available if the Security System is not enabled. Use the EditModel Action (or its CTRL+SHIFT+F1 shortcut) to invoke the Model Editor window.
In contrast to design time, at run time the Model Editor contains complete information, including recent changes made in a UI (layout, skin, etc.). By default, changes made by an end-user in a UI manually or in the Model Editor are saved to the Model.User.xafml file. This file is located in the folder with the application executable file by default. Alternatively, this file can be placed in a user's ApplicationData folder. Set the UserModelDiffsLocation configuration file key to CurrentUserApplicationDataFolder for this purpose. Another possible option is to store user settings in the database. For details, see Model Difference Storages.
Deploy and Run the Standalone Model Editor
The Model Editor can be used as a standalone utility. This approach can be used by the application administrator to edit a model of the deployed ASP.NET application or deployed Windows Forms application with the EditModel Action disabled. Do not use the standalone Model Editor for Mobile applications, because you need to rebuild your application after changing the Mobile Application Model. To use the standalone Model Editor, create a folder at a workstation or a server where the XAF application is deployed. Copy the %PROGRAMFILES(x86)%\DevExpress 19.1\Components\Tools\eXpressAppFramework\Model Editor\DevExpress.ExpressApp.ModelEditor.v19.1.exe executable and %PROGRAMFILES(x86)%\DevExpress 19.1\Components\Tools\eXpressAppFramework\Model Editor\DevExpress.ExpressApp.ModelEditor.v19.1.config configuration file from the developer workstation to the newly created folder. Copy the following assemblies to the same folder.
- All assemblies that are required by your XAF application (deployed together with the WinForms executable, or located in the Bin subfolder of the ASP.NET application).
These assemblies are available in the %PROGRAMFILES(x86)%\DevExpress 19.1\Components\Bin\Framework folder at the developer workstation.
After invoking the standalone Model Editor, you should specify an Application Model to edit via the Open Model dialog. This dialog is opened initially. You can re-invoke it later via the Open Model button at the toolbar.
To edit the Application Model of the deployed XAF application, you should specify the configuration file name only. An option to choose an assembly file and model differences path provides you with ability to edit model of a certain module outside the Visual Studio.
You can also specify an Application Model to open via command-line parameters. The standalone Model Editor has the following command-line syntax:
DevExpress.ExpressApp.ModelEditor.v19.1.exe appConfigFile | moduleAssemblyFile diffsPath | /?
Specifies an XAF application configuration file. Pass this parameter to edit the Application Model of a deployed XAF application (Windows Forms or ASP.NET).
Specifies an XAF module's assembly file (DLL). Pass this parameter followed by the diffsPath parameter to edit the Application Model of an XAF module.
This parameter specifies a model differences folder, and is required when the first parameter specifies an assembly. Typically, you should pass a module project's folder that contains a Model.DesignedDiffs.xafml file to modify.
Displays a help message on using parameters above.
So, to edit the Application Model of the deployed application, type the Model Editor executable full path in the command prompt and pass the application configuration file full path as the parameter. The Model Editor represented as a form will be invoked.
Alternatively, you can right-click the configuration file in Windows Explorer and choose the Model Editor executable via the Open With... menu item.
The Windows Forms application configuration file is <Application_Name>.Win.exe.config. The ASP.NET application configuration file is Web.config.
To edit the Application Model of an XAF module, type the Model Editor executable full path in the command prompt and pass the assembly file and the differences folder as parameters (see the table above).