Visual Studio 2010: UML modeling projects

Visual Studio 2010 introduces modeling projects that bring UML diagrams to Visual Studio. Currently it is not possible to generate classes from diagrams automatically but I don’t think it is a problem – good UML diagrams visualize different aspects of system short and clearly and they usually don’t document everything you can find in system. In this posting I will show you how to use modeling projects in Visual Studio 2010.

Creating modeling projects

Modeling projects are created as all other projects. Select New Project from menu and select Modeling Projects from templates pane. There is only one modeling project template called (very originally) Modeling Project. Select it and click Ok.

Visual Studio 2010: New modeling project

Modeling project is practically empty when it is created. On the left side of screen you should see UML Model Explorer (you can open it from View => Other Windows menu). To add new objects to UML model just right click on the title with mouse and select object type.

UML Model Explorer

Visual Studio 2010: UML model explorerYou can see UML Model Explorer on image at right. I took this screenshot after adding some objects to my modeling project so you can see how this window looks like when there is some content.

You can add new objects to you model simply by right clicking on model name and selecting object type you want to add. You can define object attributes and assign values to its properties right in the UML Model Explorer.

As a next thing let’s see some example diagrams I created. There are some features I miss (like saving diagrams as image files) but diagramming works pretty fine for program in beta status. Here are my example diagrams.

Adding new diagram

New diagrams are added to model just like any other file in other projects. Just select Add new item and select item type. You can click on image below to see it at original size.

Visual Studio 2010: New UML diagram

You can see in the item types list all diagrams you can add to modeling project. I am not very sure if this list is final or not because some diagram types are missing. But let’s hope the best as always.

Adding items to diagrams

After adding new diagram or opening existing ones you can add objects to diagram. You can find objects specific to diagram from toolbox. Screenshots below show you toolboxes for activity, class and user case diagrams.

Activity diagram toolboxClass diagram toolboxUse case diagram toolbox
Class diagram

UML class diagram shows classes in system (or subsystem) and relations between classes. Modeling projects show also attributes and methods of classes. I created simple class diagram that visualizes Party generalization and shows how this generalization can easily connect addresses to Person and Company classes.

Visual Studio 2010: UML class diagram

If you have larger model that doesn’t fit to screen well you can hide members area of classes and save some more room for classes that are not visible otherwise.

Use case diagram

UML use case diagrams illustrate use cases in system (or subsystem) and actors who are related to use cases. Also relations between use cases are shown and commented if needed. My example shows simple registration process where user is identified by its digital passport and then approved by adminitrator when registration data is saved.

Visual Studio 2010: Use case diagram

Activity diagram

As final example here is my activity diagram. It is simple one and it only shows you how activity diagrams look like – don’t look for any deep thoughts from this example.

visual-studio-2010-activity-diagram

There are also some good news about modeling projects. If you read Code stubbing with Visual Studio 2010 UML modeling thread from Visual Studio 2010 Beta 2 forums you can find out that modeling projects are built as easily extensible parts of projects and Microsoft is working also on code generation features. So, stay tuned – something big is happening!

Liked this post? Empower your friends by sharing it!

Gunnar Peipman

Gunnar Peipman is ASP.NET, Azure and SharePoint fan, Estonian Microsoft user group leader, blogger, conference speaker, teacher, and tech maniac. Since 2008 he is Microsoft MVP specialized on ASP.NET.

    18 thoughts on “Visual Studio 2010: UML modeling projects

    • November 4, 2009 at 1:13 pm
      Permalink

      From the first look at it, I thought I saw it somewhere. Then I remembered.

      It looks very much like diagrams you would find in the good old Rational Rose.

      All good comes back?

    • November 4, 2009 at 2:04 pm
      Permalink

      @Developer Art

      UML was never gone.

    • November 6, 2009 at 10:23 am
      Permalink

      Hi, nice article! Do you know if there is any way to export/save the diagrams as PNG/JPEG or such?

      Thanks

    • November 6, 2009 at 11:42 am
      Permalink

      Hi Mickel! You can copy the diagram as image to clipboard and save it using any grpahics program. Just right click on the diagram and choose copy as image (or something like that). You can also paste the image directly to documents that support graphics pasting.

    • November 9, 2009 at 3:35 pm
      Permalink

      Why don’t I have this template installed? Nor can I find it online? I would really like to check this feature out but it seems it has not been installed with my VS2010!

    • November 11, 2009 at 8:56 am
      Permalink

      Hi Tom!

      What version of VS2010 do you have? I have VS2010 Ultimate Beta 2 installed and it contains those architecture projects too

    • November 26, 2009 at 8:07 pm
      Permalink

      VS2010 Professional Beta 2 don’t have UML modeling tools?

    • February 17, 2010 at 6:39 pm
      Permalink

      Is there any way to create a link to a diagram in a normal SharePoint folder? I could export an image and save that in SharePoint, but is there a way to create at least a warm if not a hot link?

    • March 31, 2010 at 7:29 am
      Permalink

      Regarding whether UML can be used for modeling at physical level, It certainly can be. However, usability of a UML model extended by a custom profile is still worse than usability of a DSL model built specifically for that purpose. Take the database profile in this article as an example. Yes, you could model a database with it, but more than a half of the built-in attributes in UML Class diagrams are not applicable to database models, which will cause confusion and make it more difficult to use.

    • August 16, 2010 at 11:40 pm
      Permalink

      Thanks Gunnar for the details.

      Have a question here. I installed Visualization_and_Modeling_Feature_Pack and its Runtime, but still not able to see “Modeling Projects” in the new project dialog box. I choose Modeling group but it does not list “Modeling Project”.
      Please help me on how I can install Modeling project template

      Thanks,
      Meenakshi

    • August 17, 2010 at 6:46 am
      Permalink

      Hi Meenakshi! Visualization and Modeling Feature Pack is not the same thing as modeling projects. Modeling projects are part of Visual Studio 2010 Ultimate Edition.

    • August 31, 2010 at 5:14 pm
      Permalink

      Nice introduction to the VS2010 UML features.

      I have documented these features more fully in my e-book (soon to be a book) “UML Software Design with Visual Studio 2010”.

      http://www.lotontech.com/uml

    • May 27, 2011 at 7:01 am
      Permalink

      I cannot understand your question well, pimsinnum. What you exactly wish to achieve?

    • November 17, 2011 at 5:01 pm
      Permalink

      Visual Studio does not support any programming language, resolution, or the tool itself, rather than what is used to connect to the functionality encoded as a VSPackage. Once installed, the feature is available as a service.

    • January 20, 2012 at 6:45 am
      Permalink

      Regarding whether UML can be used for modeling at physical level, It certainly can be. However, usability of a UML model extended by a custom profile is still worse than usability of a DSL model built specifically for that purpose.

    • February 25, 2012 at 10:57 pm
      Permalink

      Than you very much, its been really usefull for me!

    • Pingback:Visual Studio Extension: Save UML diagram as image | Gunnar Peipman - Programming Blog

    Leave a Reply

    Your email address will not be published. Required fields are marked *