Search code examples
c#entity-framework-4data-annotationscode-firstentity-framework-ctp5

Entity Framework CTP 5 RelatedTo Attribute not working


Using Entity Framework CTP 5 I am trying to make a list of foreign keys in my class. But I keep getting an error which says RelatedTo can not be found.

Here is the code:

public class VertragsVerweis : GenericBLL
{
    [Key]
    public String Uid
    {   
        get;
        set;
    }

    public String VertagsVerweisNr
    {
        get;
        set;
    }

    public String Bezeichnung
    {
        get;
        set;
    }

    public Boolean Reparatur
    {
        get;
        set;
    }

    [RelatedTo(RelatedProperty="Artikel")]
    public List<Artikel> Artikelen
    {
        get;
        set;
    }
}

This gives me the error:

Error 2 The type or namespace name 'RelatedTo' could not be found (are you missing a using directive or an assembly reference?) C:\Documents and Settings\wep\Bureaublad\WEPProject\branches\codefirst Entity Framework\BusinessLogic\BusinessLogic\VertragsVerweisBLL.cs 37 10 BusinessLogic

For some reason it DOES recognize the Key Attribute from System.ComponentModel.DataAnnotations. Why does it not recognize RelatedTo?


Solution

  • I would recommend you upgrade to EF4.1 ... Perhaps your problem is solved with that. If not - update your question :)