0
I am working on a project using MVC5 and Entityframwork 6. I followed a tutorial to create a database from my templates.
Example of a model:
public class Side
{
public Side()
{
}
public int ID { get; set; }
public ICollection<Comment> Comments { get; set; }
public int Content { get; set; }
}
How do I now add a comment to ICollection<Comment> Comments
?
From what I’ve been reading, I have to create a function Add()
, but I don’t understand where.
I also wanted to know how this works at the level of the database, how are the comments added to the database? (I have a table for Comment
and Side
) and I have the Comment
thus defined:
public class Comment
{
public Comment()
{
}
public string Content { get; set; }
public int ID { get; set; }
public int AuthorID { get; set; }
public DateTime DatePublished { get; set; }
public DateTime DateEdited { get; set; }
public bool edited { get; set; }
public int VotesUp { get; set; }
public int VotesDown { get; set; }
}
Thank you, very complete your reply!
– ihavenokia