Entity Framework Core
A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
768 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I have a question Dbset
public class Question {
public int Id {get; set;}
public string Text {get; set;}
public virtual ICollection<Choice> Choices {get; set;} = []
Choice DbSet/Model
public class Choice
{
public int Id { get; set; }
[Required]
[MaxLength(100)]
public string Text { get; set; } = string.Empty;
[Required]
public int QuestionId { get; set; }
[JsonIgnore]
public virtual Question Question { get; set; }
}
I am sending data from angular.
{
text: "dfdfdfd",
choices: [
{ text: "choice1"},
{ text: "choice2"}
]
}
Now if i add it to the dbset, in the following way,
_context.Questions.Add(Question);
await _context.SaveChangesAsync();
It is adding only the questions to the Dbset Why are the choices being ignored?