Невозможно разрешить службу для типа' microsoft.entityframeworkcore.dbset`1 [todoapidb.models.todoitem] '
во время попытки активировать. 'Todoapidb.data.todoitemsservice'.) '< /P>
< /blockquote>
Код: Выделить всё
Program.cs
Код: Выделить всё
builder.Services.AddScoped();
< /code>
ITodoItemsService.cs
Код: Выделить всё
public interface ITodoItemsService
{
List? GetAbunch(string[] myAnimals);
}
< /code>
TodoItemsService.cs
public class TodoItemsService: ITodoItemsService
{
private readonly DbSet _todoItems;
public TodoItemsService(DbSet todoItems)
{
_todoItems = todoItems;
}
List? ITodoItemsService.GetAbunch(string[] myAnimals)
{
var animals = _todoItems.Where(i => myAnimals.Contains(i.Name))
.ToList();
return animals;
}
}
< /code>
GitHub code of the API application.
Screenshot of the error in Visual Studio:

Подробнее здесь: https://stackoverflow.com/questions/795 ... -to-be-con