public async Task <CustomEntity> Create(CustomDto customDto) { try { var entity = customDto.ToEntity(); _customRepository.Add(entity); // it will be null var testEntity = await _customRepository.GetById(entity.Id); // If everything is ok then: await _uow.Commit(); // The product will be added only after commit testEntity = await _customRepository.GetById(entity.Id); return(testEntity); } catch (Exception e) { throw e; } }