/// <inheritdoc />
public async Task<T> GetAsync<T>(Guid id, CancellationToken cancellationToken)
where T : class
{
var entity = await Set<T>().FindAsync(new[] { id }, cancellationToken);
return entity ?? throw new NotFoundException(typeof(T).Name, id);
}
The given Entity is signed with a "single", so only one Entity is allowed to get back from the DB.
call GetAsync(model.Id, cancellationToken) to receive at least one data. The Database Table contains only one Row, which should be returned.
EF Core version: 3.0 Database provider: Pomelo.EntityFrameworkCore.MySql Target framework: .Net Core 3.0 Operating system: Mac OS IDE: Rider
You need to use the DbSet.FindAsync(...) method.
In your case the cancellationToken
was interpreted as the second item of the params object[] keyValues
parameter.