【问题标题】:Entity Framework CTP 5 RelatedTo Attribute not working实体框架 CTP 5 RelatedTo 属性不起作用
【发布时间】:2011-03-31 12:39:12
【问题描述】:

使用实体框架 CTP 5 我正在尝试在我的班级中制作外键列表。 但我不断收到一条错误消息,提示找不到 RelatedTo。

代码如下:

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;
    }
}

这给了我错误:

错误 2 找不到类型或命名空间名称“RelatedTo”(您是否缺少 using 指令或程序集引用?) C:\Documents and Settings\wep\Bureaublad\WEPProject\branches\codefirst Entity Framework\BusinessLogic \BusinessLogic\VertragsVerweisBLL.cs 37 10 商业逻辑

由于某种原因,它确实识别出 System.ComponentModel.DataAnnotations 中的关键属性。为什么不识别 RelatedTo?

【问题讨论】:

    标签: c# entity-framework-4 data-annotations code-first entity-framework-ctp5


    【解决方案1】:

    AFAIK “RelatedTo”-属性没有进入 RC。支持的注释列表在第 8 节下:ADO Team blog

    编辑:我找到了我正在寻找的博客条目:EF design blog。 “RelatedTo”列在“新数据注释属性”下,他们说他们提出这些属性。

    【讨论】:

      【解决方案2】:

      我建议您升级到 EF4.1 ...也许您的问题已经解决了。如果没有 - 更新您的问题:)

      【讨论】:

        猜你喜欢
        • 2011-07-06
        • 1970-01-01
        • 1970-01-01
        • 2011-07-07
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多