Ho una classe seguente:
[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; }
}
Stavo usando Entity Framework 5, ma ora ho indignato (usando nuget) alla versione più recente - 6, dopo averlo fatto ho riscontrato un errore:
"La proprietà 'TagSourceId' non può essere configurata come proprietà di navigazione.La proprietà deve essere un tipo di entità valido e la proprietà deve avere un getter e un setter non astratto.Per le proprietà di raccolta il tipo deve implementare ICollection dove T è un tipo di entità valido . "" ExceptionType ":" System.InvalidOperationException"
Ho letto questo argomento, ma non ho riferimenti come descritto: Aggiornamento da EF5 a EF6 - le proprietà di navigazione sono interrotte
Ho avuto lo stesso problema. Ho rimosso InverseProperty
attributi InverseProperty
e il problema è stato risolto. Spero che sia d'aiuto.