Synchronizing the Model and Code
The synchronization process between the UModel .ump file (the model) and the C# or VB.NET code can be manual or automatic.
Automatic synchronization takes place once you add UModel support to your Visual Studio project (see Adding UModel Support to Visual Studio Projects ). Automatic synchronization means that, whenever you edit the code, the UModel Plug-in for Visual Studio parses the code and updates the model. Likewise, if you make changes to the model (for example, by editing a diagram), the code is updated accordingly. Manual synchronization, on the other hand, is initiated on demand, as shown below.
Both the automatic and the manual synchronization update changes in bulk, for the entire project. When UModel runs as a Visual Studio plug-in, the option to merge or update a single class is not available in the Model Tree.
The commands which control automatic or manual synchronization are available in the Project | UModel Project menu:
Code synchronization menu commands (Visual Studio 2010)
In newer versions of Visual Studio, selected menu items have a slightly different appearance:
Code synchronization menu commands (Visual Studio 2017)
The meaning of each command is as follows.
Automatic synchronize Program Code from UModel Project | This menu option is switched on by default, meaning that synchronization from model to code is set to take place automatically. To enable or disable automatic synchronization, click the menu item. |
Automatic synchronize UModel Project from Program Code | Same as above, in the opposite direction (from code to model). |
Merge Program Code from UModel Project | Updates the program code with changes made in the UModel project (same functionality as in the standalone version).
The name of this command changes to Overwrite Program Code from UModel Project, if you have set this option from Project | UModel Project | Synchronization Settings. |
Merge UModel Project from Program Code | Updates the UModel project with changes made in the program code (same functionality as in the standalone version).
The name of this command changes to Overwrite UModel Project from Program Code, if you have set this option from Project | UModel Project | Synchronization Settings. |
Cancel UModel Project / Program Code Synchronization | Enables you to cancel a synchronization operation which is in progress. When no synchronization operation is in progress, this option is disabled. |
During synchronization, the progress of the operation appears in the Visual Studio status bar, for example:
Code synchronization between code and model cannot take place in the following cases:
•Code is not parseable
•The last reverse engineering or forward engineering process encountered an error.
•The syntax check throws an error in UModel.
In such cases, the error details are displayed in the Messages window. To open the source file which contains the error, click the corresponding line in the Messages window. The cursor will be positioned on the line containing the error.
Automatic synchronization limitations
Some C# and VB.NET code modifications in Visual Studio do not trigger an internal Visual Studio event and are thus not automatically updated in UModel. In such cases, you can either perform a forced synchronization manually, or make a different modification which triggers a source file update. Manual synchronization is necessary when adding or changing the following entities:
•Default values for attributes
•Default values for operation parameters
•TemplateParameters
•TemplateBindings
•Summary section for all elements
•Remark section for all elements
•All changes in method bodies
Note that if you change any of the above-mentioned modeling elements in the model, automatic code synchronization will take place normally. There are no limitations when automatic synchronization is from model to code.
To perform a forced manual synchronization from code to model, right-click the source code file in the code editor and select Reverse engineer current file from the context menu.
If your UModel project contains the language profile for Java, then automatic synchronization is automatically disabled for that project in Visual Studio, and a message box informs you of this. Such projects must be synchronized manually (using the menu commands UModel | Merge Program Code from UModel Project, and UModel | Merge UModel Project from Program Code). Alternatively, consider using the UModel Plug-in for Eclipse (see UModel Plug-in for Eclipse ).