A transactive energy trading framework for community microgrids in apartment buildings is proposed in this paper where strategic decisions for investors are analyzed through a transactive energy sharing game (TESG). The community microgrid in the proposed setting includes a solar photovoltaic (PV) system with a battery energy storage system (BESS). A contributing factor is considered to ensure the fair share of investors and contributing owners or their tenants to achieve benefits based on this factor. In the proposed framework, the excess energy is traded with non-contributing owners through the proposed TESG and the profits are shared with contributing owners as well as with their tenants. The proposed energy trading framework also ensures the optimal utilization of solar PV and BESSs for contributing owners and their tenants. Finally, the cost-benefit analysis is performed to demonstrate the attractiveness of the proposed transactive energy trading framework. Simulation studies are carried out on a community microgrid to further justify the effectiveness and acceptability of the proposed scheme.