Я реализую функцию, которая позволяет пользователям следовать друг за другом. У меня есть таблицы базы данных:
User{UserId, FirstName, LastName etc.}
Followings{FollowerUserId, FollowingUserId, CreatedOnDate etc.}
Поэтому я добавил класс EF:
public class Follow
{
[Key, Column(Order = 1)]
public Guid FollowerUserId { get; set; }
[Key, Column(Order = 2)]
public Guid FollowUserId { get; set; }
public DateTime CreatedOnDate { get; set; }
public virtual User Follower { get; set; }
public virtual User Following { get; set; }
}
Последние два виртуальных свойства вызывают проблемы. Когда я звоню:
var model = con.Follows.Where(x => x.FollowerUserId == uid);
Я получаю следующее исключение:
Invalid column name 'Following_UserId'.
Проблема, вероятно, вызвана наличием двух объектов User в одном классе. Любая идея, как обойти это?
ОБНОВЛЕНИЕ
public class User
{
public Guid UserId { get; set; }
...
public virtual ICollection<Follow> Following { get; set; }
public virtual ICollection<Follow> Followers { get; set; }
}