Mindscape
  • Register
  • Login
  • YOUR CART IS EMPTY
home
Software
  • Developers Toolbox
  • LightSpeed
  • Raygun
  • WPF Elements
  • Web Workbench
  • Metro Elements
  • Silverlight Elements
  • NHibernate Designer
  • Phone Elements
  • WPF Diagrams
  • Simple DB management
  • Visual Tools for SharePoint
Downloads
Store
  • Buy online
  • Purchase order
  • Volume discounts
  • Reseller
  • Software license
  • Contact sales
Blog
Support
About
  • About Us
  • Contact
  • Testimonials
rss
twitter
facebook
Working with Models in the Visual Designer LightSpeed Model Explorer Workflows for Rapid Application Development Enums and Other User8209Defined Types Enums and Other User Defined Types Refactoring in the Designer Custom Views Linked Models Changing the Designer Defaults Customising the Generated Code ManytoMany Associations Designer Shortcuts and Tips

ManytoMany Associations

As discussed in the chapter Creating Domain Models, LightSpeed represents many‑to‑many associations as through associations.  A through association between A and B is implemented using a through entity, which represents an association between one A entity and one B entity.  A given A entity may be associated with multiple through entities, each of which links on to one B entity, and vice versa.

The designer provides two ways of presenting through associations.  You can choose to show just the many‑to‑many relationship, treating the through entity as an internal implementation detail, which is the most convenient approach in most cases.  Or you can choose to show the through entity explicitly, which provides you with fine control and extensibility at the expense of visual clutter.

Using an Auto Through Entity

The first option is referred to as using an auto through entity.  Auto through entities avoid cluttering up the diagram when there’s no additional data associated with the relationship, and you don’t need fine control over database mapping, eager loading, etc.  To specify an auto through entity, select the through association arrow and enter a name for the through entity in the Auto Through Entity box:

If you have an explicit through entity and it’s not adding any value, you can convert it to an auto through entity by right-clicking the through association and choosing Convert to Auto Through Entity.

Using an Explicit Through Entity

The second option is referred to as using an explicit through entity.  In this case the through entity appears on the diagram surface as a fully-fledged entity, allowing you to customise features such as database mapping and eager loading, and to associated extra data with the relationship.  For example, suppose you represent tagging by a many‑to‑many association between Contributions and Tags, and you want to record which user applied each Tag to each Contribution.  You can’t store that information on the Contribution or the Tag.  The best place to store it is therefore on the through entity which represents the contribution–tag association.  With an explicit through entity this is easy because you can work with the through entity just like any other entity.

To specify an explicit through entity, select the through association arrow and choose the through entity from the Through Entity drop-down.

When you show an explicit through entity, you must also explicitly model the one-to-many associations between the main entities and the through entity.  This allows you to control details such as foreign key column mapping.

If you have an auto through entity and you need to add extra data or fine‑tune the database mapping, you can convert it to an explicit through entity by right-clicking the through association and choosing Convert to Explicit Through Entity.

How Do Auto and Explicit Through Entities Differ?

Fundamentally, they don’t.  They result in the same code and the same database schema.  They are not different things, just different ways of showing the same thing on the design surface.

Data Products

  • LightSpeed ORM
  • NHibernate Designer
  • SimpleDB Tools
  • SharePoint Tools

DevOp Tools

  • Raygun

Visual Controls

  • WPF Elements
  • WPF Diagrams
  • Silverlight Elements
  • Phone Elements

Popular Products

  • Web Workbench

    Modern web development for Visual Studio!

  • Mindscape Megapack

    All Mindscape products for one awesome price!

Quick Links

  • Forums
  • Blog
  • Register
  • Login
  • Contact us
  • Twitter
  • Facebook
  • Google+
  • YouTube
  • Linkedin
  • Rss

© Mindscape 2025. Mindscape is a registered trademark of Mindscape Limited.

  • Terms
  • Privacy