I have to create a notes app for homework and it should contain Notes with a List of Tags as property. My generated Notes object looks like this:
public partial class Note
{
public Note()
{
this.Tags = new HashSet<Tag>();
}
public int Id { get; set; }
public string Title { get; set; }
public string Text { get; set; }
public string Author { get; set; }
public string Mail { get; set; }
public virtual ICollection<Tag> Tags { get; set; }
}
Also I have a generated Tag Object:
public partial class Tag
{
public Tag()
{
this.Notes = new HashSet<Note>();
}
public int Id { get; set; }
public string Name { get; set; }
public virtual ICollection<Note> Notes { get; set; }
}
This is done with a many to many relationship, i have no entity for NoteTags but a database table. Now how do I make it possible for the user to edit the tags for a note? I tried many things already, for example this but that did not work for me because i would have to edit the generated model.
Idk if this helps to understand my situation, here's my editortemplate tag.cshtml:
@model IEnumerable<CRUDApp.Models.Tag>
@foreach (var item in Model)
{
@Html.EditorFor(modelItem => item.Name)<br />
}
Whenever I post the form in the edit mode, Tags will be null within the Note object.