Entity Connections

Relationships

Connect your entities with UML relationships. AeroCoding generates navigation properties, foreign keys, EF Core configurations, and handles cascade behaviors automatically.

Relationship types

AeroCoding supports 7 UML relationship types. Each type affects how code is generated and how entities interact.

Relationship types in toolbar

Association

Simple reference between independent entities. Neither entity owns the other.

Example:User → ShippingAddress
Generates:Navigation property + FK

Navigable Association

Association with explicit foreign key. The arrow shows the navigation direction.

Example:Post → Author (User)
Generates:Navigation + explicit FK property

Inheritance

'Is-a' relationship. Child inherits all properties and methods from parent.

Example:Admin ▷── User
Generates:TPH/TPT inheritance mapping

Implementation

Entity implements an interface contract. Dashed line in UML.

Example:PaymentService ┄▷ IPaymentGateway
Generates:Interface implementation

Dependency

Weak dependency. Source uses target but doesn't store reference.

Example:OrderService ┄▶ EmailService
Generates:Constructor injection

Aggregation

Weak 'has-a' relationship. Child can exist independently of parent.

Example:Team ◇── Player
Generates:Optional FK (nullable)

Composition

Strong 'owns' relationship. Child cannot exist without parent. Cascade delete enabled.

Example:Order ◆── OrderItem
Generates:Required FK + cascade delete

Tip

Hover over any relationship type in the toolbar to see a visual preview of how it appears on the canvas.

Creating relationships

Connect entities by selecting a relationship type and drawing between cards.

Creating a relationship
[01]

Select relationship type

Click on a relationship type in the floating toolbar. The cursor changes to indicate connection mode.

[02]

Click source entity

Click on the entity that will be the source of the relationship. Connection handles appear on all sides.

[03]

Drag to target

Drag from the source to the target entity. A preview line follows your cursor showing the connection.

[04]

Configure properties

The relationship is created and selected. Use the properties panel to configure cardinality, names, and behavior.

Info

Press Escape at any time to cancel connection mode and return to selection mode.

Connection properties

Select any relationship to configure its properties in the right sidebar.

Connection properties panel
PropertyDescription
SourceThe entity where the relationship starts (displays the FK for navigable associations)
TargetThe entity where the relationship points to
Source CardinalityHow many source instances can participate (1, 0..1, *)
Target CardinalityHow many target instances can participate (1, 0..1, *)
Source NameNavigation property name on source entity (e.g., "posts")
Target NameNavigation property name on target entity (e.g., "author")
NullableWhether the FK can be null (optional relationship)

Cardinality

Cardinality defines how many instances can participate on each side of the relationship.

One to One

1 ─── 1

Each instance on one side relates to exactly one instance on the other.

Example:User ─── Profile
Use case:Splitting large entities, optional details

One to Many

1 ─── *

One instance relates to multiple instances. The most common relationship type.

Example:User ─── Posts
Use case:Parent-child, owner-owned patterns

Many to Many

* ─── *

Multiple instances on both sides. Requires a join table in the database.

Example:Students ─── Courses
Use case:Tags, categories, memberships

Optional One to Many

0..1 ─── *

Like 1:N but the 'one' side is optional. FK is nullable.

Example:Post ─── Category?
Use case:Optional parent, soft references

Info

Many-to-many relationships automatically generate a join table. For additional attributes on the join (like "joinedAt"), create an explicit join entity instead.
[01]

Unidirectional

Only one entity has a navigation property. Post has Author, but User doesn't have Posts. Simpler model, less coupling.

[02]

Bidirectional

Both entities can navigate to each other. User.Posts and Post.Author. More flexible but requires careful handling of circular references.

[03]

No navigation

Neither entity has a navigation property. Only the FK exists. Useful for loose coupling between bounded contexts.

Tip

Start with unidirectional relationships and add the reverse navigation only when needed. This keeps your domain model cleaner.

Delete behavior

Configure what happens to related entities when the parent is deleted.

BehaviorDescriptionUse Case
CascadeDelete all related entities when parent is deletedOrder → OrderItems (items belong to order)
RestrictPrevent deletion if related entities existCategory → Products (can't delete used category)
SetNullSet FK to null when parent is deleted (requires nullable FK)Post → Author (keep post, remove author)
NoActionDatabase takes no action, application must handleCustom business logic required

Warning

Composition relationships default to Cascade delete. Be careful when deleting aggregate roots as all owned entities will be removed.

Generated code

See how relationships translate to production code across your architecture layers.

DomainParent entity with collection
User.cs
public sealed class User : AggregateRoot
{
public string Name { get; private set; }
public string Email { get; private set; }
// Navigation property (one-to-many)
private readonly List<Post> _posts = new();
public IReadOnlyCollection<Post> Posts => _posts.AsReadOnly();
public Result<Post> AddPost(string title, string content)
{
var post = Post.Create(title, content, this);
if (post.IsFailure) return post;
_posts.Add(post.Value);
return post;
}
}
DomainChild entity with FK
Post.cs
public sealed class Post : Entity
{
public string Title { get; private set; }
public string Content { get; private set; }
// Foreign key
public Guid AuthorId { get; private set; }
// Navigation property (back-reference)
public User Author { get; private set; }
internal static Result<Post> Create(string title, string content, User author)
{
// Validation...
return Result.Ok(new Post
{
Title = title,
Content = content,
Author = author,
AuthorId = author.Id
});
}
}
InfrastructureEF Core configuration
PostConfiguration.cs
public class PostConfiguration : IEntityTypeConfiguration<Post>
{
public void Configure(EntityTypeBuilder<Post> builder)
{
builder.ToTable("posts");
builder.HasKey(e => e.Id);
builder.Property(e => e.Title)
.IsRequired()
.HasMaxLength(200);
builder.Property(e => e.Content)
.IsRequired();
// Relationship configuration
builder.HasOne(p => p.Author)
.WithMany(u => u.Posts)
.HasForeignKey(p => p.AuthorId)
.OnDelete(DeleteBehavior.Cascade);
}
}

Next steps

Continue exploring the editor capabilities.