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 似乎没有 Collection
和 Reference
的定义。这大约是第二次或第三次在 EF 中重构这种逻辑,感觉就像这样,所以我对如何重写上面的逻辑感到非常困惑。
尝试次数:
我尝试了以下操作:
- 我尝试在 VS15 中使用 intellisense,但没有找到类似的东西
- 我搜索了 EF7 问题 GitHub 页面,但没有看到任何内容
- 我也试过
dnu restore
只是为了确保升级没有对我的 project.json 锁做一些奇怪的事情。
- 使用
entity.HasKey()
代替entity.Key()
,但还没有发现其他方法可以与之媲美吗?
现在 beta8 的功能已经完成,我可能会重写我项目的重要部分。但是,现在我需要解决这些错误,以便我可以再次编译该项目。提供的任何帮助、协助和建议将不胜感激。
Collection => HasMany
Reference => HasOne
InverseReference => WithOne
问题
我在将我的 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 似乎没有 Collection
和 Reference
的定义。这大约是第二次或第三次在 EF 中重构这种逻辑,感觉就像这样,所以我对如何重写上面的逻辑感到非常困惑。
尝试次数:
我尝试了以下操作:
- 我尝试在 VS15 中使用 intellisense,但没有找到类似的东西
- 我搜索了 EF7 问题 GitHub 页面,但没有看到任何内容
- 我也试过
dnu restore
只是为了确保升级没有对我的 project.json 锁做一些奇怪的事情。 - 使用
entity.HasKey()
代替entity.Key()
,但还没有发现其他方法可以与之媲美吗?
现在 beta8 的功能已经完成,我可能会重写我项目的重要部分。但是,现在我需要解决这些错误,以便我可以再次编译该项目。提供的任何帮助、协助和建议将不胜感激。
Collection => HasMany
Reference => HasOne
InverseReference => WithOne