gpt4 book ai didi

entity-framework - 升级到 EF6 后 - 该属性无法配置为导航属性

转载 作者:行者123 更新时间:2023-12-02 03:36:08 24 4
gpt4 key购买 nike

我有以下类(class):

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

我使用的是 Entity Framework 5,但现在我已经(通过使用 nuget)升级到最新版本 - 6,之后我遇到了一个错误:

"The property 'TagSourceId' cannot be configured as a navigation property. The property must be a valid entity type and the property should have a non-abstract getter and setter. For collection properties the type must implement ICollection where T is a valid entity type.","ExceptionType":"System.InvalidOperationException"

我已阅读该主题,但我没有描述的引用资料: EF5 to EF6 upgrade - navigation properties are broken

最佳答案

我遇到了同样的问题。我删除了 InverseProperty 属性,问题就解决了。希望对您有所帮助。

关于entity-framework - 升级到 EF6 后 - 该属性无法配置为导航属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23334685/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com