Entity Framework CTP 5 RelatedTo Attribute not working

﹥>﹥吖頭↗ 提交于 2019-12-12 01:48:22

问题


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?


回答1:


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




回答2:


AFAIK the "RelatedTo"-Attribute did not make it into the RC. List of supported annotions is here under section 8: ADO Team blog

EDIT: I found the blog entry I was looking for originaly: EF design blog. "RelatedTo" is listed under "New Data Annotation Attributes", where they say that they propose these attributes.



来源:https://stackoverflow.com/questions/5499969/entity-framework-ctp-5-relatedto-attribute-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!