У меня есть простой API, который состоит из трех уровней данных:
Аккаунты> Пользователи> Адреса
API успешно загружает адреса для пользователей, но выдает исключение, определяющееотношения между клиентами и пользователями.
Unhandled Exception: System.InvalidOperationException: Unable to determine the relationship represented by navigation property 'ClientModel.Users' of type 'List<UserModel>'. Either manually configure the relationship, or ignore this property using the '[NotMapped]' attribute or by using 'EntityTypeBuilder.Ignore' in 'OnModelCreating'.
Вот модели, которые выглядят одинаково для меня:
public class ClientModel
{
public string Id { get; set; }
public string Type { get; set; }
public string DisplayName { get; set; }
public string Email { get; set; }
public long Phone { get; set; }
public string Photo { get; set; }
public string Source { get; set; }
public string CreatedAt { get; set; }
public int AccountsCount { get; set; }
public double AccountsBalance { get; set; }
public double AccountsBalancePending { get; set; }
public double AccountsDonations { get; set; }
public double AccountsBalanceAch { get; set; }
public double AccountsBalanceIra { get; set; }
public List<UserModel> Users { get; set; }
public UserModel Advisor { get; set; }
}
public class UserModel
{
public string Id { get; set; }
public string ClientId { get; set; }
public ClientModel Client { get; set; }
public string Role { get; set; }
public bool Primary { get; set; }
public string Email { get; set; }
public string Password { get; set; }
public string Token { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Photo { get; set; }
public string Birthday { get; set; }
public long Phone { get; set; }
public List<AddressModel> Address { get; set; }
}
public class AddressModel
{
public string Id { get; set; }
public string UserId { get; set; }
public UserModel User { get; set; }
public string Street { get; set; }
public string StreetSecondary { get; set; }
public string City { get; set; }
public string State { get; set; }
public string Country { get; set; }
public string PostalCode { get; set; }
}