I have 3 entities:
Questionnaire.cs
:
public class Questionnaire
{
public int Id { get; set; }
public string Name { get; set; }
I think you need to have a navigation property of question in your answer because answer should have an question Id . You have this FK already you just need a nav property
Your model class look like this
public class Answer
{
public int Id { get; set; }
public string UserId { get; set; }
public string TextAnswer { get; set; }
// added in model
public Question Question { get; set; }
}
and query like this
var answers = ctx.Answers.Include(q=>q.Question).Where(a =>a.UserId=="1").ToList();