I'm working on a project using MVC5 and EntityFramwork 6. I followed a tutorial to create a database from my templates.
Example of a template:
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 read, I have to create a Add()
function, but I do not understand where.
I also wanted to know how this works at the database level, how are the comments added to the database? (I have a table for Comment
and Side
) and I have Comment
defined like this:
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; }
}