AddScoped Cause System.AggregateException: 'Einige Dienste können nicht konstruiert werden (Fehler bei der Validierung dC#

Ein Treffpunkt für C#-Programmierer
Anonymous
 AddScoped Cause System.AggregateException: 'Einige Dienste können nicht konstruiert werden (Fehler bei der Validierung d

Post by Anonymous »

Ich untersuche, wie man API in .NET 8 schreibe. Wie löste ich es? Todoapidb.data.todoItemService ':

Diener nicht in der Lage, den Typ' Microsoft.EntityFrameworkcore.dbset`1 [toDoapidb.models.todoItem] '

während zu aktivieren, um' todoapidb.data. /todoapidb.data zu aktivieren ''. /> < /blockquote>

Code: Select all

Program.cs
:

Code: Select all

builder.Services.AddScoped();
< /code>
ITodoItemsService.cs
:

Code: Select all

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:
Image

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post