public abstract class RepositoryBase<T> : IRepository<T> where T : class
{
private ShopCoreDbContext dbContext;
private readonly DbSet<T> dbSet; //here
protected IDbFactory DbFactory { get; private set; }
protected ShopCoreDbContext DbContext
{
get => dbContext ?? (dbContext = DbFactory.Init());
}
protected RepositoryBase(IDbFactory dbFactory)
{
DbFactory = dbFactory;
dbSet = DbContext.Set<T>();
}
public virtual T Add(T entity)
{
return dbSet.Add(entity); //err here
}
}
With IDbSet nothing happen. But IDbSet interface no longer exists in entity core. This is error detail:
cannot implicitly convert type Microsoft.entityframeworkcore.changetracking.entityentry to T
It requires it must be an interface.
So what should I do now?