Multiple 1-N Relationship

Topics: Writing modules
Mar 14, 2012 at 9:26 AM
Edited Mar 14, 2012 at 9:30 AM

Basically i'm doing a 1-N relationship. The code below works as expected because of the naming convention.
public class PackagePartRecord : ContentPartRecord
{
     public virtual string PackageId { get; set; }
     public virtual PackageVersionPartRecord PackageVersionPartRecord { get; set; }
}

public class PackageVersionPartRecord : ContentPartRecord
{
     public virtual string Version { get; set; }
     public virtual string Description { get; set; }
}

If i'm going to have multiple reference to PackageVersion like below, how do i name the property and the migration file?
class PackagePartRecord : ContentPartRecord
{
     public virtual string PackageId { get; set; }
     public virtual PackageVersionPartRecord RecommendedVersion { get; set; }
     public virtual PackageVersionPartRecord FreeVersion { get; set; }
     public virtual PackageVersionPartRecord PaidVersion { get; set; }
}
Coordinator
Mar 14, 2012 at 9:38 AM

As long as the column that you declare in the migration is the name of the relation property followed by _Id you should be fine.

Mar 14, 2012 at 9:48 AM

Thanks! Works now. Never thought its so simple. Looks like i have to re-read the documentation again