Implement function to upsert a building entity