You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
The implementation of IRepositoryAsync<T, TId>.AddAsync(T entity) is wrong #444
Summary:
The use of _dbContext.Set<T>().AddAsync(entity) is wrong based on EF Core documentation. Instead, use .Add(entity).
Explanation:
BlazorHero.CleanArchitecture.Application.Interfaces.Repositories.IRepositoryAsync<T, TId> has a method signature 'AddAsync(T entity)' which is implemented in BlazorHero.CleanArchitecture.Infrastructure.Repositories.RepositoryAsync<T, TId>.
However, EF Core 6 documentation clearly states that .AddAsync() method should not be used by developers:
This method is async only to allow special value generators, such as the one
used by 'Microsoft.EntityFrameworkCore.Metadata.SqlServerValueGenerationStrategy.SequenceHiLo',
to access the database asynchronously. For all other cases the non async method
should be used.
Fix:
In IRepositoryAsync<T, TId>, Rename 'AddAsync(T entity)' to 'Add(T entity)'
The implementation of IRepositoryAsync<T, TId>.Add(T entity), in the RepositoryAsync<T, TId>` class must be:
Activity