What does this error message mean?
Only one constructor executes. The dependency injection framework has no idea which constructor to execute. Add one constructor with both parameters you intend to inject. I think you'll be very interested in reading .NET 5 dependency injection fundamentals which covers standard patterns.
public class IndexModel : PageModel
{
private readonly ILogger<IndexModel> _logger;
private readonly WebApplication10Context _db;
public IndexModel(WebApplication10Context db, ILogger<IndexModel> logger)
{
_db = db;
_logger = logger;
}
public IEnumerable<Book> Books { get; set; }
public async Task OnGet()
{
Books = await _db.Book.ToListAsync();
}
}