My solution should work well with: ASP.NET MVC 4, EF5, Code First, Visual Studio 2012 Express, SQL Server 2012 Express.
I need to store many tags with a place object. In another question it was suggested I use a List to achieve this:
asp.net MVC 4, tagging places - best practice (eg Pub, Store, Restaurant)
ie
public List<String> Tags {get;set;}
If I just add that it doesn't get persisted in the database at all. How can I make it persist?
Thanks.
Update
This needs a many to many relationship - eg a place might be tagged Cafe and Cycle Shop. There are many cafe's and cycle shops.
public class Place
{
public Place()
{
// Set default value of dateAdded to now
DateAdded = DateTime.Now;
}
[ScaffoldColumn(false)]
public virtual int PlaceID { get; set; }
public virtual List<Tag> Tags { get; set; }
[ScaffoldColumn(false)]
[DisplayName("Date Added")]
public virtual DateTime DateAdded { get; set; }
[Required(ErrorMessage = "Place Name is required")]
[StringLength(100)]
public virtual string Name { get; set; }
public virtual string URL { get; set; }
[DisplayName("Contact Name")]
public virtual string ContactName { get; set; }
public virtual string Address { get; set; }
public virtual string City { get; set; }
[DisplayName("Post Code")]
public virtual string PostCode { get; set; }
public virtual string Website { get; set; }
public virtual string Phone { get; set; }
[EmailAddress(ErrorMessage = "Please enter valid email")]
public virtual string Email { get; set; }
public virtual string About { get; set; }
public virtual string Image { get; set; }
}