本文介绍了升级到EF6后 - 属性不能被配置为导航属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有下面的类:
[Table("TagSource")]
public class TagSource
{
public TagSource()
{
this.DataSources = new HashSet<DataSource>();
}
[Key]
public int TagSourceId { get; set; }
...
public bool IsHistorical { get; set; }
public Nullable<int> ModifiedEntryId { get; set; }
...
public int? AttachedTagSourceId { get; set; }
[ForeignKey("AttachedTagSourceId"), InverseProperty("TagSourceId")]
public virtual TagSource AttachedTagSource { get; set; }
[ForeignKey("ModifiedEntryId"), InverseProperty("TagSourceId")]
public virtual TagSource ModifiedEntry { get; set; }
}
我是用实体框架5,但现在我已经upraged(通过使用的NuGet)到最新的版本 - 这样做之后,我遇到错误6:
I was using Entity Framework 5, but now I have upraged (by using nuget) to newest version - 6, after doing that I'm encountering an error:
属性TagSourceId'不能被配置为一个导航属性,该属性必须是一个有效的实体类型和属性应该有一个非抽象的getter和setter。对于集合属性的类型必须实现的ICollection其中T是有效的实体类型,ExceptionType:System.InvalidOperationException
我已阅读的话题,但我有这样描述的引用:
EF5到EF6升级 - 导航属性被打破
I have read that topic, but i have no references like described:EF5 to EF6 upgrade - navigation properties are broken
推荐答案
我有同样的问题。我删除 InverseProperty
属性和问题解决。希望它帮助。
I had the same problem. I removed InverseProperty
attributes and the problem solved. Hope it helps.
这篇关于升级到EF6后 - 属性不能被配置为导航属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!