public virtual void Add(TEntity entity, CancellationToken cancelationToken = default(CancellationToken)) { EntityState state = context.Entry(entity).State; if (state == EntityState.Detached) { context.Set <TEntity>().Attach(entity); } context.Set <TEntity>().AddAsync(entity, cancelationToken); }