Reputation: 17493
I'm setting my first steps in Visual Studio's class diagrams for a C# project.
In the class diagram, I have already managed to create a new class, add fields, properties and methods, make an association from a single class to another single class, and automatically generate the corresponding code. I have also already generated a class diagram from an existing C# project.
Two things I've not succeeded in, and which are quite crucial:
I'm working with Visual Studio 2017, enterprise edition, version 15.9.36.
Does anybody know what I can do? (Are those known bugs, am I doing something wrong and what should I do instead, am I using a wrong version of Visual Studio for this, ...?)
Thanks in advance
Upvotes: 0
Views: 2723
Reputation: 1038
I reproduced the first problem. You could try to right-click the class diagram and select Show as Association(one to one) or Show as Collection Association(one to many) to show the connections between the class diagrams.
For one-to-many relationships, you can use list. Here is a simple example:
class Person
{
public string Name { get; set; }
public int Age { get; set; }
public List<Family> Fmailies { get; set; }
//Code automatically generated when the class diagram creates an Association
internal Family Family
{
get => default;
set
{
}
}
}
class Family
{
public string Name { get; set; }
public string Relation { get; set; }
}
Corresponding class diagram:
Edit: It is normal to create new classes when using classes that are not in the class diagram. Association is based on existing attributes. You could create attributes first, and then establish associations.
I think the association between the classes may be detectable, but it is not explicitly shown in the class diagram.
Currently, I have not found a way to automatically display the association in visual studio. You could display the association manually.
Upvotes: 1