Mapowanie modeli asp.net

0

Witam,
chciałem się dowiedzieć jedną rzecz, otóż napisałem klasy dwóch modeli, Question i AnswersForQuestions. Pomapowałem tak jak na zrzutach ekranu. Uruchamiam apkę i daję tam localhost/AnswersForQuestions i mogę dodawać tam odpowiedzi, ale jest problem, bo nie ma nigdzie możliwości wybrania pytania, do którego dane odpowiedzi mają zostać dodane. Co jest nie tak w tym kodziku?

 
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;

namespace Aplikacja.Models
{
    public class AnswersForQuestion
    {
        [Key]
        public int AnswersForQuestionsId { get; set; }
        public AnswersForQuestion()
        {
            this.Diet = new HashSet<Diet>();
        }

        [Required]
        [StringLength(1000, MinimumLength = 3)]
        [Display(Name = "Odpowiedź 1:")]
        public string AnswerA { get; set; }

        [Required]
        [StringLength(1000, MinimumLength = 3)]
        [Display(Name = "Odpowiedź 2:")]
        public string AnswerB { get; set; }

        [Required]
        [StringLength(1000, MinimumLength = 3)]
        [Display(Name = "Odpowiedź 3:")]
        public string AnswerC { get; set; }

        [Required]
        [StringLength(1000, MinimumLength = 3)]
        [Display(Name = "Odpowiedź 4:")]
        public string AnswerD { get; set; }

        public virtual Question Question { get; set; }

        public virtual ICollection<Diet> Diet { get; set; }
    }
}
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;

namespace Aplikacja.Models
{
    public class Question
    {
     public Question()
        {
            this.AnswersForQuestion = new HashSet<AnswersForQuestion>();
        }
        [Display(Name = "ID")]
        public int QuestionId { get; set; }

        [Required]
        [StringLength(1000, MinimumLength = 10)]
        [Display(Name = "Nazwa:")]
        public string Text { get; set; }

        public virtual User user { get; set; }

        public virtual ICollection<AnswersForQuestion> AnswersForQuestion { get; set; }

    }
} 

Z góry dzięki.

1

Podejrzewam ze problemy są raczej w widoku i/lub kontrolerze.

0

Popatrzę co jest nie tak. ;)

1 użytkowników online, w tym zalogowanych: 0, gości: 1