从EF5迁移到EF6:InversePropertyAttribute是否已损坏?

时间:2013-11-04 22:17:27

标签: c# entity-framework entity-framework-6

我有类似下面代码的类设置。

public abstract class Record<T>
where T : class
{
    [Key]
    public long Id { get; set; }

    public long MasterId { get; set; }

    [ForeignKey("MasterId")]
    public virtual T Master { get; set; }

    [InverseProperty("Master")]
    public virtual ICollection<T> Suggestions { get; set; }
}

这允许我创建类似下面的类,其中最小的样板代码可以有“建议” - 稍微更改,然后在批准时合并。

public class Concrete : Record<Concrete>
{
    public string Foo { get; set; }
}

在EF5中,这曾经完美无缺地运作。但是,我现在在运行时中收到以下错误消息:

  

实体类型'Foo.Models.Concrete'的导航属性   “建议”   refer与'Foo.Models.Record`1 [[Foo.Models.Concrete,Foo,   Version = 1.0.0.0,Culture = neutral,PublicKeyToken = null]]'在其中反向       导航属性'Master'被声明。

有没有办法解决这个问题,还是有更好的设计结构可以用来解决这个问题?

0 个答案:

没有答案