Introduction to IBM Rational Modeling Extension for Microsoft .NET

How to migrate your IBM Rational XDE for Visual Studio projects to the new generation of IBM Rational modeling tools

Learn how to import your models from IBM® Rational® XDE™ for Visual Studio version 2003 to the new generation of IBM Rational modeling tools for use with IBM® Rational® Modeling Extension for Microsoft® .NET, as you migrate your .NET projects from Visual Studio® 2003 to Visual Studio 2005.

Share:

Manivannan P. Kalidasan (manivannanpk@in.ibm.com), Software Engineer, IBM

Manivannan P. Kalidasan is a software developer for IBM Rational Software Architect, IBM Rational Software Modeler, and IBM Rational Systems Developer.



06 March 2007

Also available in Chinese

The XDE C# Code Model importer is a utility provided as part of the IBM Rational Modeling Extension for Microsoft .NET product, which is designed to be installed into IBM® Rational® Software Modeler but can also be installed into IBM® Rational® Software Architect or IBM® Rational® Systems Developer. Hereafter, for convenience, we will reference only Rational Software Modeler instead of referencing all three products, and IBM Rational Modeling Extension for Microsoft .NET is referred to as simply Rational Modeling Extension. By using the XDE code model import utility, you can migrate your XDE models to Rational Software Modeler, and prepare the imported code models and corresponding C# source code for use with Rational Modeling Extension. You can then use the modeling and transformation capabilities of Rational Software Modeler and Rational Modeling Extension to get the same benefits offered by Rational XDE for Visual Studio. Get started by following these step-by-step instructions.

Prerequisites

You need to have the following products installed on your computer and also be familiar with them:

  • Rational Software Modeler (or Rational Software Architect or Rational Systems Developer) version 7.0.0.1 or higher, with Rational Modeling Extension for .NET
  • Microsoft Visual Studio 2003
  • Visual Studio 2005
  • Rational XDE Developer for Visual Studio version 2003

Take a look at Figure 1, which illustrates the entire migration path, before reading further about the details involved in each step.

Figure 1. The migration path
Figure 1: Diagram of the migration path

Some things to know

A C# project in a XDE .NET 2003 solution contains two types of artifacts: C# source files and XDE models. You can import the XDE models into your Rational Software Modeler/Rational Modeling Extension workspace by using the existing XDE Base Model Importer. Within Rational XDE, certain models have special status. These are the "code models", each of which is synchronized to the C# source code of a single C# project, and the "assembly models" that provide a UML representation of the .NET Framework libraries or other assemblies that are referenced by a C# project. Within Rational XDE there can also be "miscellaneous" models (also known as "content models") which are UML conceptual models that are not bound in any way to C# code. In Rational XDE, cross-model references can also exist. Code models will contain references to assembly models. Elements in content models may contain references to elements in code models, and vice-versa. For best results you should use the XDE Base Model Import utility to import all the models in a Visual Studio Solution at the same time, as a "closure" i.e., a set of models within which all cross-model references can be resolved (no missing models, thus no broken references).

The next section explains the migration process in detail. The migration process can be divided into three major phases:

  • Migrating the Visual Studio 2003 solution that contains XDE models, to Visual Studio 2005
  • Importing the XDE models to Rational Software Modeler using the base XDE Model Import utility
  • Choosing the Model Driven Development (MDD) Software Architecture Management Protocol you plan to use, and then importing (visualizing) the Visual Studio 2005 Solution within Rational Software Modeler. During this step, the imported models that had the special status of Code Models and Assembly Models in Rational XDE, are modified to prepare them to be used with Rational Software Modeler/Rational Modeling Extension modeling and transformation capabilities C# code.

Note:You can migrate the Visual Studio 2003 solution to Visual Studio 2005 by using the migration utility provided with Visual Studio 2005.

Preparing the XDE base models and C# code

Perform the following steps to prepare the XDE base models and the C# project code for the Code Model Importer:

  1. Make a backup copy of the Visual Studio 2003 solution, including the XDE models.
  2. Migrate the XDE .NET 2003 solution to Visual Studio 2005 by using the Visual Studio 2005 migration utility. There is nothing special you need to do at this step, just follow the standard Visual Studio instructions. Rational XDE cannot be installed into Visual Studio 2005, but that is of no concern. The XDE models (files with .mdx extension) will simply be treated by Visual Studio 2005 as miscellaneous files of unrecognized type and they will not be altered in any way.
  3. Create UML projects in your Rational software workspace, to contain the imported XDE models. Whereas in Rational XDE you might have multiple code models in multiple C# projects, and each C# project would also contain its own set of assembly models, and content models would reside in a separate, non-C#, miscellaneous project, you need not replicate that structure in Rational Software Modeler. If you wish, all the imported XDE files can be placed into a single UML project. Or you can plan to allocate them to multiple UML projects. It's your choice. Don't worry about where the assembly models will go, just put them in any UML project. They will be needed during the import process, but afterward you will be deleting them so it does not matter where you put them.
  4. Use the base XDE Model Importer (XMI) to import the XDE models (.mdx files) from the Visual Studio 2005 solution. Import them all, as a closure (if you didn't read Some Things To Know above, go back and read it now). The detailed steps for using base XMI and the wizard it provides, are provided as part of Rational Software Modeler product documentation.
  5. Open the .NET solution in the Visual Studio 2005 IDE.

Note:
The .NET solution should now remain open in your Visual Studio IDE throughout the remaining process of completing the code model import, as well as thereafter whenever you are using the Rational Modeling Extension Visualizer or the transformation components.

Migrating projects using the C# Code Model Importer

Perform the following steps to import visualizations of the Visual Studio 2005 projects and complete the process of preparing the imported XDE code models for use with Rational Software Modeler/Rational Modeling Extension:

  1. Launch the XDE .NET C# Code Model Importer by clicking File > Import > Other > XDE .NET Solution. (Caution: there is also File > Import > Other > .NET Solution, which is not the one you want to use at this step)
  2. In the first page of the wizard, either enter the full path or locate the solution (.sln) file that corresponds to the .NET 2005 solution that you want to import. (See the Rational Modeling Extension product Help sections on C# Visualization for details on how to use the options related to assemblies in this page. Note that you can import only one .NET solution to your Rational software workspace, using either the .NET Solution importer or the XDE .NET Solution (Code Model) importer.)
  3. Click Next. In the next page of the wizard, you will see a table. Each row contains information about a C# project in the .NET solution that you are importing. The first and second columns of the table show the names of the C# project in the Visual Studio 2005 Solution and the Rational Software Modeler workspace, respectively. In the third column, enter the full path or locate the UML model (.emx file) that corresponds to each C# project (this should be the model imported at step 4 above, that is the migrated version of what was the code model for that C# project in Rational XDE).

    Now you must make a key decision:

    You are about to perform the following steps to import visualizations of the Visual Studio 2005 projects and complete the process of preparing the imported XDE code models for use with Rational Software Modeler/Rational Modeling Extension. But Rational Software Modeler/Rational Modeling Extension support a number of different ways of working with models and code, and none of them works precisely the way Rational XDE does. Rational XDE uses a persisted UML semantic model that is synchronized to code, to support visualization or visual editing of the code via the model. Instead, Rational Software Modeler supports these choices (among others):

    1. Direct visual editing of the code. No UML model is required. We call it simply code modeling. And this is exactly the same principle used by the Class Designer feature of Visual Studio 2005.
    2. Mixed Modeling, which involves the use of both direct code modeling, and UML conceptual modeling, where you can mix depictions of code and UML elements together in diagrams and create and depict relationships between them. It may also involve the use of a special replace UML elements option when using transformations to generate code from conceptual UML.
    3. Architecture Reconciliation, which involves the use of transformation from UML to code, reverse transformation from code to UML, and the use of a reconciliation assistant to detect changes that have occurred in the model and the code since the last round-trip, and to resolve the deltas in favor of model or code.
    4. Conceptual Models Drive Development, which involves the use of code-generating transformations, in a workflow that is constrained to say that all architecturally significant changes will be made first in models, and then propagated into code.

    If you plan to use direct visual editing of code, you actually don't have to bother completing the steps of preparing the XDE code models for use with Rational Software Modeler/Rational Modeling Extension. In fact, you could simply delete the imported code models and assembly models. But if you plan to use any of the other ways of working, you will make an important decision as you complete the remaining steps…

  4. In the fourth column, titled Replace UML Elements, you can choose either the Replace option or the Don't Replace option. If you intend to practice Mixed Modeling as described above, use Replace. If you intend to practice Architecture Reconciliation or Conceptual Models Drive Development, use Don't Replace.
  5. Click Finish to start the migration.

Operations to perform during migration

The following operations are performed by C# Code Model Importer during the migration process to make the code model and the C# code compatible with the Rational software modeling and transformation components. Many of these operations are either performed or skipped, depending upon the option that you selected previously for Replace UML Elements.

Back up the UML code model file

(This operation is performed regardless of the option that you chose for Replace UML Elements.)

The Code Model Importer makes a backup copy of the specified UML (.emx) code model file for a C# project. It is saved in the same location as the specified model file. The name of the backup copy uses the name of the specified model file followed by _backup. For example, if the specified model file name is Model.emx, then the backup copy will be called Model_backup.emx.

Create the mapping model

(The mapping model is created only if you choose the Don't Replace option under Replace UML Elements.)

The importer also creates a mapping model that captures the existing mapping of UML model elements to C# source files. This means that the mapping model represents the information about which C# source file contains the code element that corresponds to each model element in the UML code model. This mapping model can be specified in a UML-to-C# transformation configuration so that the transformation retains the existing organization of code elements among files.

Replace references to Visual Studio .NET assembly types

(This operation is performed only if you choose the Don't Replace option under Replace UML Elements.)

The UML model elements corresponding to C# code elements may contain references to types from Visual Studio .NET assemblies. For example, a UML class may have an attribute of a System.String type. When you import the XDE base model using the XDE Base Model Importer, this type will be replaced by a reference to the corresponding element in the model file, system.emx.

However, the Rational Modeling Extension Visualizer maintains its own representation of the types from .NET assemblies, and the transformation components understand only the references to this representation. Therefore the references to Visual Studio .NET assembly types in the UML model are replaced by the visualizer elements that correspond with those assembly types. This step is necessary to make the UML model compatible with the Rational Modeling Extension Visualizer and transformation components.

Migrate your profiles

(This operation is performed only if you choose the Don't Replace option under Replace UML Elements.)

The Rational Modeling Extension component defines and uses its own C# profile, which contains stereotypes that are applied to UML elements to represent various C# code types and constructs. As a part of the code model migration process, the importer applies this new C# profile to the specified UML code model. This makes the migrated code model compatible with the C# transformation components, which enables the model to participate in UML-to-C# (forward) and C#-to-UML (reverse) transformations.

Migrate your packages

(This operation is performed only if you choose the Don't Replace option under Replace UML Elements.)

Any package in the UML code model with a name that contains period or full stop (.) characters is expanded to a sequence of nested name spaces to eliminate those periods. The sequence of the name spaces depends on the number of periods in the name.

For example, if there is a package in the UML model with name of xde.importer.examples, it will be replaced by the sequence of three nested name spaces that include xde, importer and examples, so that xde contains importer and importer contains examples. The container of the original package, xde.importer.examples, will contain the outer-most package, xde, and the contents of the original xde.importer.examples package will become the contents of the inner-most package, examples. This is because the C# transformation components require the nested name spaces to be represented explicitly, rather than by using periods in the name.

Replace your UML elements

(This operation is performed only if you choose the Don't Replace option under Replace UML Elements.)

All of the UML elements in the specified UML code model are replaced by shortcuts to the corresponding code elements in the C# source files. By double-clicking these elements, you can reach the corresponding code elements in the source files.

Choose this option only if you do not want to use the C# modeling and transformation capabilities to manipulate the existing elements in the migrated code model. This is because the C# visualizer elements (or the shortcuts) are read-only. However, you can add new UML elements to the migrated model, modify them, and generate code by running the UML-to-C# transformation.

Tip:
In case you choose this option by mistake and run the migration process, you can easily restore your original code model. Simply delete the migrated model and use the backup model file that you created during the migration process.

Tag code elements

(This operation is performed only if you choose the Don't Replace option under Replace UML Elements.)

The code elements in the C# source files are tagged as <@generated> if the Round-Trip Engineering Synchronization policy (in the original XDE code model) is enabled for the model elements that correspond to those code elements.

The code elements that are not tagged during this step are not deleted or overwritten by the UML-to-C# (forward) transformation. Thus, if you delete or rename the model element (the UML class) corresponding to a C# class that does not have the tag, and then you run a forward transformation, the class is not modified in the C# source file. To change this behavior, you can add the <@generated> tag to the comments of the C# class in the source file. Thereafter, changes that you make to the UML class in the model will be applied to the C# class in the source code. Read the documentation of the UML-to-C# (forward) transformation component for more details.

Resources

Learn

Get products and technologies

  • Download evaluation versions of IBM Rational Software Modeler, Rational Software Architect Rational Systems Developer. IBM Rational Modeling Extension for Microsoft .NET should be available as a trial download soon.

Discuss

Comments

developerWorks: Sign in

Required fields are indicated with an asterisk (*).


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Information in your profile (your name, country/region, and company name) is displayed to the public and will accompany any content you post, unless you opt to hide your company name. You may update your IBM account at any time.

All information submitted is secure.

Choose your display name



The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

Required fields are indicated with an asterisk (*).

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


All information submitted is secure.

Dig deeper into Rational software on developerWorks


static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Rational
ArticleID=199115
ArticleTitle=Introduction to IBM Rational Modeling Extension for Microsoft .NET
publish-date=03062007