I'm using Entity Framework Core 2.0 to map exist DB, the DB has two tabels: Teams
and SupportTeam
.
Team Fields: ID, Name
TeamSupport: TeamID (ForeignKey on Team Table), SupportTeamID (ForeignKey on Team Table)
I tried to map them as following:
public class Team
{
public int Id { get; set; }
public string name { get; set; }
public List<TeamSupport> SupportTeams { get; set; }
}
public class TeamSupport
{
public int TeamId { get; set; }
public virtual Team Team { get; set; }
public int SupportTeamId { get; set; } // In lack of better name.
public virtual Team SupportTeam { get; set; }
}
But I had the follwing error when i run "add-migration":
Unable to determine the relationship represented by navigation property 'Team.SupportTeams' of type 'List'. Either manually configure the relationship, or ignore this property using the '[NotMapped]' attribute or by using 'EntityTypeBuilder.Ignore' in 'OnModelCreating'.