For example, let say I have 4 different entity that each implement a Add() method that add the entity to the database :
public class Profile
{
...
publi
The solution to your problem is to be more explicit with the definition of the generic constraint. Define the constraint as TEntity must be a sub-class of Entitywhere TEntity : Entity
instead of where TEntity : class
public abstract class Entity where TEntity : Entity
{
protected DbContext _dbContext;
protected Entity()
{
this._dbContext = new SMTDBContext();
}
public void Add()
{
this._dbContext.Set().Add((TEntity)this);
this._dbContext.SaveChanges();
}
}