This depends on the type of electric razor you own. A dry shaving electric razor will generally not need shaving cream; indeed, adding shaving cream may damage the blades and mechanisms that operate it. If the electric razor is built for wet shaving (often in the form a dual dry or wet shave model), then it’s okay to use shaving cream when in wet shave mode, provided the manual says it’s appropriate. It is important to read the manual accompanying your electric razor, as this will make it clear whether or not you can use shaving cream when using it.