I want to know if there's a way to add a validator where an author needs to be selected on a combobox otherwise it will display an error.
In my application I have three models, Books, Authors and the join table Rel_Book_Author.
public class Book
{
[Key]
[Display(Name = "Id")]
[Column("book_id")]
public int book_id { get; set; }
[Display(Name = "Title")]
[Column("liv_title")]
[Required(ErrorMessage = "Every book needs a title")]
public string liv_title { get; set; }
}
public class Author
{
[Key]
[Display(Name = "Id")]
[Column("aut_id")]
public int aut_id { get; set; }
[Display(Name = "Author's Name")]
[Column("aut_name")]
public string aut_name { get; set; }
public ICollection<Rel_Book_Author> BookAuthors { get; set; }
}
public class Rel_Book_Author
{
[Column("hla_aut_id")]
public int aut_id { get; set; }
public Author Author { get; set; }
[Column("hla_book_id")]
public int book_id { get; set; }
public Book Book { get; set; }
}