我有一个错误:
参数交流:提供的通用参数的数量未 等于通用类型定义的Arity。参数名称: 实例化
public class EfCoreRepository<TContext, TEntity> : IEfCoreRepository<TEntity>
where TContext : IEfCoreDbContext
where TEntity : class
{
....
}
这是接口
public interface IEfCoreRepository<TEntity> where TEntity : class
我像那样注册的地方
services.AddTransient(typeof(IEfCoreRepository<>), typeof(EfCoreRepository<,>));
我更新了接口为
public interface IEfCoreRepository<TContext, TEntity>
where TContext : IEfCoreDbContext
where TEntity : class
然后像这样注册
services.AddTransient(typeof(IEfCoreRepository<,>), typeof(EfCoreRepository<,>));