public virtual void InsertOrUpdateGraph(TEntity entityGraph) { context.Set <TEntity>().Add(entityGraph); if (entityGraph.State != ModelState.Added) { context.ApplyStateChanges(); } }