I am trying to implement a generic GetById(T id) method which will cater for types which may have differing ID types. In my example, I have an entity which has
GetById(T id)
You should remove the constraint on TId from your Repository class
Repository
public abstract class Repository : IRepository where TEntity : class, IEntity { public virtual TEntity GetById(TId id) { return context.Set().Find(id); } }