public virtual void Add(T entity) { DbEntityEntry dbEntityEntry = dbContext.Entry(entity); if (dbEntityEntry.State != EntityState.Detached) { dbEntityEntry.State = EntityState.Added; } else { DbSet.Add(entity); } }