views:

267

answers:

1

Does EF 4 support unidirectional one-to-many associations, as in:

public class Parent
{
  public int Id { get; set; }
  public string Something { get; set; }
  public List<Child> AllMyChildren { get; set; }
}

public class Child
{
  public int Id { get; set; }
  public string Anotherthing { get; set; }
  // I don't want a back-reference to the Parent!
  // public int ParentId { get; set; }
}

When I try to compile my project with an association between Parent and Child where End2 Navigation is blank (because I unchecked the End2 Navigation Property checkbox in the Add Association dialog), I get

Error 2027: No mapping specified for the following EntitySet/AssociationSet - Child.

UPDATE:

And what if I just have a List or similar property on Parent rather than a List? Do I need to create a wrapping type to hold the String so that I can also hold a back-reference to Parent?

A: 

This screencast has a demo of how to do a one-directional association in EF 4. This should be supported.

Craig Stuntz