I am new in ASP.NET and I am learning MVC and EF. I could not match any existing answer to my question so please help. Code first is used.
I get an error: Error Here is the code for Action method in the Controller:
public ActionResult Index()
{
var book = _context.Books.Include(b => b.Genre).ToList();
return View(book);
}
Here is the Book.cs Model:
public class Book
{
public int Id { get; set; }
[Required]
[StringLength(255)]
public string Name { get; set; }
[Required]
[StringLength(17)]
public string ISBN { get; set; }
[Required]
public string Author { get; set; }
[Required]
public string Publisher { get; set; }
public Genre Genre { get; set; }
[Required]
[Display(Name = "Genre")]
public byte GenreId { get; set; }
[Display(Name = "Published Year")]
public DateTime PublishedYear { get; set; }
[Display(Name = "Release Date")]
public DateTime ReleaseDate { get; set; }
[Display(Name = "Number in Stock")]
[Range(1, 20, ErrorMessage = "The field Number in Stock must be between 1 and 20")]
public byte NumberInStock { get; set; }
Here are DbSets:
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
public DbSet<Customer> Customers { get; set; }
public DbSet<Book> Books { get; set; }
public DbSet<MembershipType> MembershipTypes { get; set; }
public DbSet<Genre> Genres { get; set; }
And here is the table: Columns in table
So when i debug the project here is the exception: Error = The function evaluation requires all threads to run. Debug