Answer the question
In order to leave comments, you need to log in
How to specify parent for child model?
There is one model:
public class User
{
[Key]
public int Id { get; set; }
public string Email { get; set; }
public string FirstName{ get; set; }
public string LastName { get; set; }
public string Password { get; set; }
public int CreatedAt { get; set; }
public ICollection<Video> Videos { get; set; }
}
public class Video
{
[Key]
public int Id { get; set; }
public string Title { get; set; }
public string Description { get; set; }
public string File { get; set; }
public string Hash { get; set; }
public int CreatedAt { get; set; }
public int Views { get; set; }
}
VideosRep.Add(new Video()
{
Title = videoTitle,
File = FileName,
Description = videoDescription,
Hash = HashString,
CreatedAt = MyHelpers.GetUtcTimeStamp(),
User_Id = /// ругается на отсутствие поля у модели оно и понятно
}
);
public User User { get; set; }
VideosRep.Add(new Video()
{
Title = videoTitle,
File = FileName,
Description = videoDescription,
Hash = HashString,
CreatedAt = MyHelpers.GetUtcTimeStamp(),
User = UsersRep.Users.Where(c => c.Id == userId).First()
}
);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question