Mary of Modena ( Maria Beatrice Eleonora Anna Margherita Isabella d'Este ; -- ) was Queen consort of England , Scotland and Ireland . She was also the second wife of King James II . Mary of Modena ( Maria Beatrice Anna Margherita Isabella d'Este ; â `` ) was Queen consort of England , Scotland and Ireland as the second wife of King James II and VII .