I have the model (code first) & database (SQL Server) setup with many to many relationship & seeding fine:
A Place can have many tags (eg Restaurant, bar, cafe) - and tags can belong to many places.
Place
[ScaffoldColumn(false)]
public virtual int PlaceID { get; set; }
[Required(ErrorMessage = "Place Name is required")]
[StringLength(100)]
public virtual string Name { get; set; }
[Required]
public virtual string Address {get;set;}
public virtual string ImageLogo {get;set;}
public virtual string ImageBackground {get;set;}
Tag
public virtual int TagID { get; set; }
[Required]
public virtual string Name { get; set; }
[Required]
public virtual string NamePlural { get; set; }
public virtual ICollection<Place> Places { get; set; }
EF Migrations has generated a junction table with TagID & PlaceID and I can add Places with multiple tags fine in my Seed method. There are about 50 tags - all seeded.
What I would like to do is have a Create view form - that allows users to select from all the tags - maybe with check boxes (open to alternatives), some async textbox etc? Which are then saved with the model.
This data will be entered by an administrator - speed of entry is most important (doesn't have to be 100% idiot proof).
I also need to be able to edit the place - and have those tags show up appropriately to be removed or others added.
Also the best way to handle deletion of places - delete records in junction table first?
What is best practice in all of the above?
Thanks.