0

I am trying to write some T4 templates to generate basic class definitions from my physical UML class diagram that lives in my domain project. However, all of the T4 examples I have seen on the web for generating code from UML class diagrams are based on modeling projects (.modelproj). Is it possible to use T4 templates to examine and generate code for UML class diagrams that ARE NOT within a VS2010 modeling project? I cannot use use class diagrams in a modeling project as they are logical and hence any class properties are restricted to four primitive types.

1 Answer 1

1

There are 2 kinds of Visual Studio class diagram: the UML .classdiagram files that can only be opened in a .modelproj project; and the .NET class diagrams that you can get from a code file using the "View Class Diagram" command in Solution Explorer. I'm not quite clear which one you're working with, since if you've got the latter kind, you'd already have some code.

BTW, you can actually use properties of any type in a UML class diagram. In the model explorer, right-click to get the shortcut menu on the root node, and choose Add External Type. You can enter any namespace and type name. Then that type appears in the menu for setting the types of class properties.

Sign up to request clarification or add additional context in comments.

2 Comments

I don't see the 'Add External Type' menu option when I right click on the model explorer root mode. Anyway, I have now resolved this by using .edmx models instead. I have edited and copied the T4 template code that you get in an Entity Framework project in order to generate our NHibernate based entities.
I will accept your reply as an answer as you provided me with a good explanation regarding the differences between the two class diagrams.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.