Gunnar Peipman's ASP.NET blog

ASP.NET, C#, SharePoint, SQL Server and general software development topics.






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: Creating 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 Explorer You 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: Add new diagram to modeling project

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.

Visual Studio 2010: Activity diagram toolbox Visual Studio 2010: Class diagram toolbox Visual Studio 2010: Use 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!

kick it on pimp it 顶 Progg it Shout it
Shout it!


balapraveen said:

Thanks to show this new feature... eager to work on it...

# November 4, 2009 7:03 AM

Developer Art said:

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 8:13 AM

Remco Ros said:

@Developer Art

UML was never gone.

# November 4, 2009 9:04 AM

Mickel said:

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


# November 6, 2009 5:23 AM

DigiMortal said:

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 6, 2009 6:42 AM

Tom said:

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 9, 2009 10:35 AM

DigiMortal said:

Hi Tom!

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

# November 11, 2009 3:56 AM

Mike said:

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

# November 26, 2009 3:07 PM

That Guy said:

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?

# February 17, 2010 1:39 PM

virtual office london said:

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.

# March 31, 2010 3:29 AM

Meenakshi said:

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



# August 16, 2010 7:40 PM

DigiMortal said:

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 17, 2010 2:46 AM

Tony Loton said:

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".

# August 31, 2010 1:14 PM

pimsainnum said:

How to connect all model and complied to exe file.

# May 26, 2011 11:33 PM

DigiMortal said:

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

# May 27, 2011 3:01 AM

Testking 646-985 said:

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.

# November 17, 2011 12:01 AM

Testking 70-642 said:

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.

# January 20, 2012 1:45 AM

Gilberto Bernon said:

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

# February 25, 2012 5:57 PM