Entity Framework ASP.NET Beta 8 中缺少键、集合、引用定义的 7 个错误

Entity Framework 7 Errors from Key, Collection, Reference definitions missing in ASP.NET Beta 8

问题

我在将我的 beta7 应用程序升级到 beta8 时遇到问题。我遇到了超过 50 个错误的问题,但现在已经将其减少到 EF7。是stack overflow的朋友和网友推荐的,我特​​地问了这个问题。

Entity Framework错误

Error CS1061 'EntityTypeBuilder<Unit>' does not contain a definition for 'Collection' and no extension method 'Collection' accepting a first argument of type 'EntityTypeBuilder<Unit>' could be found (are you missing a using directive or an assembly reference?) SampleProject.DNX 4.5.1

我对 Reference 也有同样的错误。

我的 DbContext.cs 文件中的 OnModelCreating(ModelBuilder builder) 方法中有以下代码。

builder.Entity<Unit>(entity =>
 {
     entity.HasKey(unit => unit.UnitId);
     entity.Collection(unit => unit.UnitBins).InverseReference(bin =>  bin.BinUnit)
                    .ForeignKey(bin => bin.UnitId).Required(true);
     entity.Reference(u => u.RefUnitType).InverseReference().ForeignKey<Unit>      (u   => u.RefUnitTypeId).Required();
            });

问题是 EntityBuilder 似乎没有 CollectionReference 的定义。这大约是第二次或第三次在 EF 中重构这种逻辑,感觉就像这样,所以我对如何重写上面的逻辑感到非常困惑。

尝试次数:

我尝试了以下操作:

现在 beta8 的功能已经完成,我可能会重写我项目的重要部分。但是,现在我需要解决这些错误,以便我可以再次编译该项目。提供的任何帮助、协助和建议将不胜感激。

Collection => HasMany
Reference => HasOne
InverseReference => WithOne