Код: Выделить всё
Unable to determine the relationship represented by navigation 'Player.Alliance' of type 'Alliance'. Either manually configure the relationship, or ignore this property using the '[NotMapped]' attribute or by using 'EntityTypeBuilder.Ignore' in 'OnModelCreating'
Код: Выделить всё
public class Player
{
public Guid PlayerID { get; init; }
// Navigation properties
public virtual Alliance Alliance { get; init; }
// Properties
public int GovernorIdentifier { get; set; }
public string Name { get; set; }
public int Power { get; set; }
public int Killpoints { get; set; }
public Civilization Civilization { get; set; }
public int HighestPower { get; set; }
public int Victory { get; set; }
public int Defeat { get; set; }
public int Dead { get; set; }
public int ScoutTimes { get; set; }
public int ResourcesGathered { get; set; }
public int ResourceAssistance { get; set; }
public int AllianceHelpTimes { get; set; }
}
Код: Выделить всё
public class Alliance
{
// Primary key
public Guid AllianceID { get; init; }
// Navigation properties
public Player Leader { get; init; }
public ICollection
Players { get; init; }
// Properties
public string Tag { get; set; }
public string Name { get; set; }
public int Territories { get; set; }
public int GiftLevel { get; set; }
public int PlayerCapacity { get; set; }
}
Как реализовать двустороннее отношение «один к одному» (не убивайте меня, если это неправильная терминология) между игроком и альянсом? В моем конкретном случае использования, как мне убедиться, что у Alliance есть список игроков и свойство навигации для игрока, который является лидером альянса, а у игрока есть свойство навигации для альянса, частью которого он является?
Подробнее здесь: https://stackoverflow.com/questions/724 ... een-models
Мобильная версия